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

LibJS: Implement Temporal.ZonedDateTime.prototype.offsetNanoseconds

This commit is contained in:
Linus Groh 2021-08-04 23:17:07 +01:00 committed by Andreas Kling
parent dd36593c72
commit f937e9b966
4 changed files with 43 additions and 0 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.offsetNanoseconds).toBe(0);
});
test("custom offset", () => {
const timeZone = new Temporal.TimeZone("+01:30");
const zonedDateTime = new Temporal.ZonedDateTime(0n, timeZone);
expect(zonedDateTime.offsetNanoseconds).toBe(5400000000000);
});
});
test("errors", () => {
test("this value must be a Temporal.ZonedDateTime object", () => {
expect(() => {
Reflect.get(Temporal.ZonedDateTime.prototype, "offsetNanoseconds", "foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.ZonedDateTime");
});
});