mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:37:47 +00:00
LibJS: Implement Intl.Locale.prototype.calendars property
This commit is contained in:
parent
028a6b90b1
commit
e9bc35d805
6 changed files with 90 additions and 4 deletions
|
@ -0,0 +1,29 @@
|
|||
describe("errors", () => {
|
||||
test("called on non-Locale object", () => {
|
||||
expect(() => {
|
||||
Intl.Locale.prototype.calendars;
|
||||
}).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
expect(Array.isArray(new Intl.Locale("en").calendars)).toBeTrue();
|
||||
expect(new Intl.Locale("en").calendars).toEqual(["gregory"]);
|
||||
|
||||
expect(Array.isArray(new Intl.Locale("ar").calendars)).toBeTrue();
|
||||
expect(new Intl.Locale("ar").calendars).toEqual(["gregory"]);
|
||||
});
|
||||
|
||||
test("extension keyword overrides default data", () => {
|
||||
expect(new Intl.Locale("en-u-ca-islamicc").calendars).toEqual(["islamic-civil"]);
|
||||
expect(new Intl.Locale("en", { calendar: "dangi" }).calendars).toEqual(["dangi"]);
|
||||
|
||||
expect(new Intl.Locale("ar-u-ca-ethiopic-amete-alem").calendars).toEqual(["ethioaa"]);
|
||||
expect(new Intl.Locale("ar", { calendar: "hebrew" }).calendars).toEqual(["hebrew"]);
|
||||
|
||||
// Invalid calendars also take precedence.
|
||||
expect(new Intl.Locale("en-u-ca-ladybird").calendars).toEqual(["ladybird"]);
|
||||
expect(new Intl.Locale("en", { calendar: "ladybird" }).calendars).toEqual(["ladybird"]);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue