mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 14:57:34 +00:00
LibJS: Add calendarName: "critical" option to toString() methods
This is a normative change in the Temporal spec.
See: e715a50
This commit is contained in:
parent
192aa75279
commit
4a167cfbec
9 changed files with 73 additions and 15 deletions
|
@ -13,12 +13,16 @@ describe("correct behavior", () => {
|
|||
"2021-07-01[u-ca=iso8601]"
|
||||
);
|
||||
expect(plainYearMonth.toString({ calendarName: "never" })).toBe("2021-07");
|
||||
expect(plainYearMonth.toString({ calendarName: "critical" })).toBe(
|
||||
"2021-07-01[!u-ca=iso8601]"
|
||||
);
|
||||
|
||||
plainYearMonth = new Temporal.PlainYearMonth(2021, 7, { toString: () => "foo" }, 6);
|
||||
expect(plainYearMonth.toString()).toBe("2021-07-06[u-ca=foo]");
|
||||
expect(plainYearMonth.toString({ calendarName: "auto" })).toBe("2021-07-06[u-ca=foo]");
|
||||
expect(plainYearMonth.toString({ calendarName: "always" })).toBe("2021-07-06[u-ca=foo]");
|
||||
expect(plainYearMonth.toString({ calendarName: "never" })).toBe("2021-07-06");
|
||||
expect(plainYearMonth.toString({ calendarName: "critical" })).toBe("2021-07-06[!u-ca=foo]");
|
||||
|
||||
plainYearMonth = new Temporal.PlainYearMonth(0, 1);
|
||||
expect(plainYearMonth.toString()).toBe("0000-01");
|
||||
|
@ -47,7 +51,7 @@ describe("errors", () => {
|
|||
}).toThrowWithMessage(TypeError, "Not an object of type Temporal.PlainYearMonth");
|
||||
});
|
||||
|
||||
test("calendarName option must be one of 'auto', 'always', 'never'", () => {
|
||||
test("calendarName option must be one of 'auto', 'always', 'never', 'critical'", () => {
|
||||
const plainYearMonth = new Temporal.PlainYearMonth(2021, 7);
|
||||
expect(() => {
|
||||
plainYearMonth.toString({ calendarName: "foo" });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue