mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 11:58:13 +00:00
LibJS: Parse new Intl.DisplayNames "type" and "languageDisplay" options
Intl.DisplayNames v2 adds "calendar" and "dateTimeField" types, as well as a "languageDisplay" option for the "language" type. This just adds these options to the constructor.
This commit is contained in:
parent
853ccab9af
commit
71f7e67a20
6 changed files with 102 additions and 14 deletions
|
@ -35,6 +35,12 @@ describe("errors", () => {
|
|||
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option fallback");
|
||||
});
|
||||
|
||||
test("language display option is invalid ", () => {
|
||||
expect(() => {
|
||||
new Intl.DisplayNames("en", { type: "language", languageDisplay: "hello!" });
|
||||
}).toThrowWithMessage(RangeError, "hello! is not a valid value for option languageDisplay");
|
||||
});
|
||||
|
||||
test("missing type options ", () => {
|
||||
expect(() => {
|
||||
new Intl.DisplayNames("en", {});
|
||||
|
@ -48,10 +54,18 @@ describe("normal behavior", () => {
|
|||
});
|
||||
|
||||
test("all valid types", () => {
|
||||
["language", "region", "script", "currency"].forEach(type => {
|
||||
["language", "region", "script", "currency", "calendar", "dateTimeField"].forEach(type => {
|
||||
expect(() => {
|
||||
new Intl.DisplayNames("en", { type: type });
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
test("all valid language displays", () => {
|
||||
["dialect", "standard"].forEach(languageDisplay => {
|
||||
expect(() => {
|
||||
new Intl.DisplayNames("en", { type: "language", languageDisplay: languageDisplay });
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue