summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-07-05 12:28:21 -0400
committerLinus Groh <mail@linusgroh.de>2022-07-06 16:56:42 +0200
commit4d32f38a76f81f77d6a19d39df3303c813c31f96 (patch)
tree6873bd91b6d9b8b0bca913a52178264d35acb776 /Userland/Libraries/LibJS/Tests
parente9bc35d805f931746aedfb183a2d155feedd1375 (diff)
downloadserenity-4d32f38a76f81f77d6a19d39df3303c813c31f96.zip
LibJS: Partially implement Intl.Locale.prototype.collations property
We do not yet parse collation data from the CLDR. This stubs out the collations property, analogous to Intl.supportedValuesOf.
Diffstat (limited to 'Userland/Libraries/LibJS/Tests')
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.collations.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.collations.js b/Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.collations.js
new file mode 100644
index 0000000000..e7732c2a58
--- /dev/null
+++ b/Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.collations.js
@@ -0,0 +1,29 @@
+describe("errors", () => {
+ test("called on non-Locale object", () => {
+ expect(() => {
+ Intl.Locale.prototype.collations;
+ }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
+ });
+});
+
+describe("normal behavior", () => {
+ test("basic functionality", () => {
+ expect(Array.isArray(new Intl.Locale("en").collations)).toBeTrue();
+ expect(new Intl.Locale("en").collations).toEqual(["default"]);
+
+ expect(Array.isArray(new Intl.Locale("ar").collations)).toBeTrue();
+ expect(new Intl.Locale("ar").collations).toEqual(["default"]);
+ });
+
+ test("extension keyword overrides default data", () => {
+ expect(new Intl.Locale("en-u-co-compat").collations).toEqual(["compat"]);
+ expect(new Intl.Locale("en", { collation: "compat" }).collations).toEqual(["compat"]);
+
+ expect(new Intl.Locale("ar-u-co-reformed").collations).toEqual(["reformed"]);
+ expect(new Intl.Locale("ar", { collation: "reformed" }).collations).toEqual(["reformed"]);
+
+ // Invalid collations also take precedence.
+ expect(new Intl.Locale("en-u-co-ladybird").collations).toEqual(["ladybird"]);
+ expect(new Intl.Locale("en", { collation: "ladybird" }).collations).toEqual(["ladybird"]);
+ });
+});