1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 16:17:47 +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:
Luke Wilde 2022-11-02 19:24:47 +00:00 committed by Linus Groh
parent 192aa75279
commit 4a167cfbec
9 changed files with 73 additions and 15 deletions

View file

@ -11,12 +11,16 @@ describe("correct behavior", () => {
expect(plainMonthDay.toString({ calendarName: "auto" })).toBe("07-06");
expect(plainMonthDay.toString({ calendarName: "always" })).toBe("1972-07-06[u-ca=iso8601]");
expect(plainMonthDay.toString({ calendarName: "never" })).toBe("07-06");
expect(plainMonthDay.toString({ calendarName: "critical" })).toBe(
"1972-07-06[!u-ca=iso8601]"
);
plainMonthDay = new Temporal.PlainMonthDay(7, 6, { toString: () => "foo" }, 2021);
expect(plainMonthDay.toString()).toBe("2021-07-06[u-ca=foo]");
expect(plainMonthDay.toString({ calendarName: "auto" })).toBe("2021-07-06[u-ca=foo]");
expect(plainMonthDay.toString({ calendarName: "always" })).toBe("2021-07-06[u-ca=foo]");
expect(plainMonthDay.toString({ calendarName: "never" })).toBe("2021-07-06");
expect(plainMonthDay.toString({ calendarName: "critical" })).toBe("2021-07-06[!u-ca=foo]");
});
});
@ -27,7 +31,7 @@ describe("errors", () => {
}).toThrowWithMessage(TypeError, "Not an object of type Temporal.PlainMonthDay");
});
test("calendarName option must be one of 'auto', 'always', 'never'", () => {
test("calendarName option must be one of 'auto', 'always', 'never', 'critical'", () => {
const plainMonthDay = new Temporal.PlainMonthDay(7, 6);
expect(() => {
plainMonthDay.toString({ calendarName: "foo" });