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:
parent
20300bd7c4
commit
96a0c201d5
4 changed files with 37 additions and 0 deletions
|
@ -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");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue