mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 00:17:45 +00:00
LibJS: Change test conditions to pass in all time zones
Mostly slapping "timeZone: UTC" on DateTimeFormat tests (we have other tests for specific time zones). Also pick dates that are not on DST boundaries in some time zones where that matters.
This commit is contained in:
parent
1fb8408aa2
commit
9cd93944b8
6 changed files with 49 additions and 39 deletions
|
@ -1,5 +1,5 @@
|
|||
test("basic functionality", () => {
|
||||
let d = new Date(2000, 2, 1);
|
||||
let d = new Date(2000, 11, 15);
|
||||
|
||||
d.setHours(2);
|
||||
expect(d.getHours()).toBe(2);
|
||||
|
|
|
@ -37,20 +37,26 @@ describe("correct behavior", () => {
|
|||
const d1 = new Date(Date.UTC(1989, 0, 23, 7, 8, 9, 45));
|
||||
|
||||
test("defaults to date", () => {
|
||||
expect(d0.toLocaleDateString("en")).toBe("12/7/2021");
|
||||
expect(d1.toLocaleDateString("en")).toBe("1/23/1989");
|
||||
expect(d0.toLocaleDateString("en", { timeZone: "UTC" })).toBe("12/7/2021");
|
||||
expect(d1.toLocaleDateString("en", { timeZone: "UTC" })).toBe("1/23/1989");
|
||||
|
||||
expect(d0.toLocaleDateString("ar")).toBe("٧/١٢/٢٠٢١");
|
||||
expect(d1.toLocaleDateString("ar")).toBe("٢٣/١/١٩٨٩");
|
||||
expect(d0.toLocaleDateString("ar", { timeZone: "UTC" })).toBe("٧/١٢/٢٠٢١");
|
||||
expect(d1.toLocaleDateString("ar", { timeZone: "UTC" })).toBe("٢٣/١/١٩٨٩");
|
||||
});
|
||||
|
||||
test("dateStyle may be set", () => {
|
||||
expect(d0.toLocaleDateString("en", { dateStyle: "full" })).toBe(
|
||||
expect(d0.toLocaleDateString("en", { dateStyle: "full", timeZone: "UTC" })).toBe(
|
||||
"Tuesday, December 7, 2021"
|
||||
);
|
||||
expect(d1.toLocaleDateString("en", { dateStyle: "full" })).toBe("Monday, January 23, 1989");
|
||||
expect(d1.toLocaleDateString("en", { dateStyle: "full", timeZone: "UTC" })).toBe(
|
||||
"Monday, January 23, 1989"
|
||||
);
|
||||
|
||||
expect(d0.toLocaleDateString("ar", { dateStyle: "full" })).toBe("الثلاثاء، ٧ ديسمبر ٢٠٢١");
|
||||
expect(d1.toLocaleDateString("ar", { dateStyle: "full" })).toBe("الاثنين، ٢٣ يناير ١٩٨٩");
|
||||
expect(d0.toLocaleDateString("ar", { dateStyle: "full", timeZone: "UTC" })).toBe(
|
||||
"الثلاثاء، ٧ ديسمبر ٢٠٢١"
|
||||
);
|
||||
expect(d1.toLocaleDateString("ar", { dateStyle: "full", timeZone: "UTC" })).toBe(
|
||||
"الاثنين، ٢٣ يناير ١٩٨٩"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue