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

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

This commit is contained in:
Linus Groh 2021-08-19 00:26:09 +01:00
parent 73d888e9e6
commit 0e201fbb42
3 changed files with 42 additions and 0 deletions

View file

@ -0,0 +1,23 @@
describe("correct behavior", () => {
test("length is 0", () => {
expect(Temporal.PlainDate.prototype.toJSON).toHaveLength(0);
});
test("basic functionality", () => {
let plainDate;
plainDate = new Temporal.PlainDate(2021, 7, 6);
expect(plainDate.toJSON()).toBe("2021-07-06");
plainDate = new Temporal.PlainDate(2021, 7, 6, { toString: () => "foo" });
expect(plainDate.toJSON()).toBe("2021-07-06[u-ca=foo]");
});
});
describe("errors", () => {
test("this value must be a Temporal.PlainDate object", () => {
expect(() => {
Temporal.PlainDate.prototype.toJSON.call("foo");
}).toThrowWithMessage(TypeError, "Not a Temporal.PlainDate");
});
});