mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:47:45 +00:00
LibJS: Implement Intl.ListFormat.prototype.resolvedOptions
This commit is contained in:
parent
5c06a91dfa
commit
ef94c73a01
3 changed files with 65 additions and 0 deletions
|
@ -0,0 +1,38 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 0", () => {
|
||||
expect(Intl.ListFormat.prototype.resolvedOptions).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("all valid types", () => {
|
||||
["conjunction", "disjunction", "unit"].forEach(type => {
|
||||
const en = new Intl.ListFormat("en", { type: type });
|
||||
expect(en.resolvedOptions()).toEqual({
|
||||
locale: "en",
|
||||
type: type,
|
||||
style: "long",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("all valid styles", () => {
|
||||
["long", "short", "narrow"].forEach(style => {
|
||||
const en = new Intl.ListFormat("en", { style: style });
|
||||
expect(en.resolvedOptions()).toEqual({
|
||||
locale: "en",
|
||||
type: "conjunction",
|
||||
style: style,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("locales with extensions", () => {
|
||||
const en = new Intl.ListFormat("en-t-en");
|
||||
expect(en.resolvedOptions().locale).toBe("en");
|
||||
|
||||
const es419 = new Intl.ListFormat("es-419-u-1k-aaa");
|
||||
expect(es419.resolvedOptions().locale).toBe("es-419");
|
||||
|
||||
const zhHant = new Intl.ListFormat(["zh-Hant-x-aaa"]);
|
||||
expect(zhHant.resolvedOptions().locale).toBe("zh-Hant");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue