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

LibJS: Implement Temporal.Instant.prototype.toJSON()

This commit is contained in:
Linus Groh 2021-08-31 00:24:46 +01:00 committed by Andreas Kling
parent 463eb361ad
commit c171aa40a8
3 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,18 @@
describe("correct behavior", () => {
test("length is 0", () => {
expect(Temporal.Instant.prototype.toJSON).toHaveLength(0);
});
test("basic functionality", () => {
const instant = new Temporal.Instant(1625614921123456789n);
expect(instant.toJSON()).toBe("2021-07-06T23:42:01.123456789Z");
});
});
describe("errors", () => {
test("this value must be a Temporal.Instant object", () => {
expect(() => {
Temporal.Instant.prototype.toJSON.call("foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.Instant");
});
});