Connector of date and time style can be " at " or ", "

macOS system ICU is shipping new CLDR, but it has many overrides on the top of it to make the formatted output suitable for the system.
And in timedatestyle-en.js tests, we intentionally override the CLDR data with the different format.
This change modifies the test to accept that alternative output.
This commit is contained in:
Yusuke Suzuki 2020-09-19 11:27:58 -07:00 committed by Rick Waldron
parent fd12f5bc6b
commit 333da4198a
1 changed files with 9 additions and 7 deletions

View File

@ -10,10 +10,10 @@ locale: [en-US]
const date = new Date("1886-05-01T14:12:47Z");
const dateOptions = [
["full", "Saturday, May 1, 1886", " at "],
["long", "May 1, 1886", " at "],
["medium", "May 1, 1886", ", "],
["short", "5/1/86", ", "],
["full", "Saturday, May 1, 1886"],
["long", "May 1, 1886"],
["medium", "May 1, 1886"],
["short", "5/1/86"],
];
const timeOptions = [
@ -84,18 +84,20 @@ for (const [timeStyle, expected12, expected24] of timeOptions) {
}
}
for (const [dateStyle, expectedDate, connector] of dateOptions) {
for (const [dateStyle, expectedDate] of dateOptions) {
for (const [timeStyle, expectedTime] of timeOptions) {
const dtf = new Intl.DateTimeFormat("en-US", {
dateStyle,
timeStyle,
timeZone: "UTC",
});
const result1 = [expectedDate, ", ", expectedTime].join("");
const result2 = [expectedDate, " at ", expectedTime].join("");
const dateString = dtf.format(date);
assert.sameValue(
dateString,
[expectedDate, connector, expectedTime].join(""),
[result1, result2].includes(dateString),
true,
`Result for date=${dateStyle} and time=${timeStyle}`
);
}