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

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

This commit is contained in:
Linus Groh 2021-08-19 00:49:12 +01:00
parent 70fb7bf57e
commit c1c8d7861c
3 changed files with 42 additions and 0 deletions

View file

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