1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 19:25:10 +00:00
serenity/Userland/Libraries/LibJS/Tests/builtins/Temporal/TimeZone/TimeZone.from.js
Linus Groh d527eb62da LibJS: Support non-UTC time zones in Temporal :^)
We can now recognize & normalize all time zones from the IANA time zone
database and not just 'UTC', which makes the LibJS Temporal
implementation a lot more useful! Thanks to the newly added LibTimeZone,
this was incredibly easy to implement :^)

This already includes these recent editorial changes in the Temporal
spec: 27bffe1
2022-01-11 22:17:39 +01:00

23 lines
1.2 KiB
JavaScript

describe("normal behavior", () => {
test("length is 1", () => {
expect(Temporal.TimeZone.from).toHaveLength(1);
});
test("basic functionality", () => {
const timeZone = new Temporal.TimeZone("UTC");
const timeZoneLike = {};
const zonedDateTimeLike = { timeZone: {} };
expect(Temporal.TimeZone.from(timeZone)).toBe(timeZone);
expect(Temporal.TimeZone.from(timeZoneLike)).toBe(timeZoneLike);
expect(Temporal.TimeZone.from(zonedDateTimeLike)).toBe(zonedDateTimeLike.timeZone);
expect(Temporal.TimeZone.from("UTC").id).toBe("UTC");
expect(Temporal.TimeZone.from("GMT").id).toBe("UTC");
expect(Temporal.TimeZone.from("Etc/UTC").id).toBe("UTC");
expect(Temporal.TimeZone.from("Etc/GMT").id).toBe("UTC");
// FIXME: https://github.com/tc39/proposal-temporal/issues/1993
// expect(Temporal.TimeZone.from("Etc/GMT+12").id).toBe("Etc/GMT+12");
// expect(Temporal.TimeZone.from("Etc/GMT-12").id).toBe("Etc/GMT-12");
expect(Temporal.TimeZone.from("Europe/London").id).toBe("Europe/London");
expect(Temporal.TimeZone.from("Europe/Isle_of_Man").id).toBe("Europe/London");
});
});