mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:27:35 +00:00
LibJS: Implement Temporal.PlainYearMonth.prototype.toJSON()
This commit is contained in:
parent
70fb7bf57e
commit
c1c8d7861c
3 changed files with 42 additions and 0 deletions
|
@ -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");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue