forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibJS: Implement Intl.ListFormat.prototype.resolvedOptions
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...nd/Libraries/LibJS/Tests/builtins/Intl/ListFormat/ListFormat.prototype.resolvedOptions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
}); | ||
}); |