From 2afcf1d3d980720b832da1cd5e120d08b1a5efb4 Mon Sep 17 00:00:00 2001 From: PhistucK Date: Fri, 20 Jul 2018 11:12:10 +0300 Subject: [PATCH] Added a legal part types test --- .../prototype/formatToParts/main.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/intl402/DateTimeFormat/prototype/formatToParts/main.js b/test/intl402/DateTimeFormat/prototype/formatToParts/main.js index d00414b126..75e7686f3d 100644 --- a/test/intl402/DateTimeFormat/prototype/formatToParts/main.js +++ b/test/intl402/DateTimeFormat/prototype/formatToParts/main.js @@ -38,3 +38,39 @@ compareFTPtoFormat(['ar'], { day: 'numeric', year: '2-digit' }, Date.now()); + +const actualPartTypes = new Intl.DateTimeFormat('en-us', { + weekday: 'long', + era: 'long', + year: 'numeric', + month: 'numeric', + day: 'numeric', + hour: 'numeric', + minute: 'numeric', + second: 'numeric', + hour12: true, + timeZone: 'UTC', + timeZoneName: 'long' +}).formatToParts(Date.UTC(2012, 11, 17, 3, 0, 42)) + .map(function (part) { return part.type; }); + +const legalPartTypes = [ + "weekday", + "era", + "year", + "month", + "day", + "hour", + "minute", + "second", + "literal", + "dayPeriod", + "timeZoneName" +]; + +actualPartTypes.forEach( + function (type) { + assert( + legalPartTypes.indexOf(type) !== -1, + type + " is not a legal type"); + });