1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:27:35 +00:00

LibJS: Implement Temporal.ZonedDateTime.prototype.offset

This commit is contained in:
Linus Groh 2021-08-04 23:18:19 +01:00 committed by Andreas Kling
parent f937e9b966
commit 6c345c8107
6 changed files with 45 additions and 2 deletions

View file

@ -0,0 +1,21 @@
describe("correct behavior", () => {
test("basic functionality", () => {
const timeZone = new Temporal.TimeZone("UTC");
const zonedDateTime = new Temporal.ZonedDateTime(0n, timeZone);
expect(zonedDateTime.offset).toBe("+00:00");
});
test("custom offset", () => {
const timeZone = new Temporal.TimeZone("+01:30");
const zonedDateTime = new Temporal.ZonedDateTime(0n, timeZone);
expect(zonedDateTime.offset).toBe("+01:30");
});
});
test("errors", () => {
test("this value must be a Temporal.ZonedDateTime object", () => {
expect(() => {
Reflect.get(Temporal.ZonedDateTime.prototype, "offset", "foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.ZonedDateTime");
});
});