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

LibJS: Implement Temporal.ZonedDateTime.prototype.toInstant()

This commit is contained in:
Linus Groh 2021-08-05 21:48:23 +01:00
parent 20300bd7c4
commit 96a0c201d5
4 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,21 @@
describe("correct behavior", () => {
test("length is 0", () => {
expect(Temporal.ZonedDateTime.prototype.toInstant).toHaveLength(0);
});
test("basic functionality", () => {
const timeZone = new Temporal.TimeZone("UTC");
const zonedDateTime = new Temporal.ZonedDateTime(1625614921000000000n, timeZone);
const instant = zonedDateTime.toInstant();
expect(instant).toBeInstanceOf(Temporal.Instant);
expect(instant.epochNanoseconds).toBe(1625614921000000000n);
});
});
test("errors", () => {
test("this value must be a Temporal.ZonedDateTime object", () => {
expect(() => {
Temporal.ZonedDateTime.prototype.toInstant.call("foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.ZonedDateTime");
});
});