diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-09-01 22:16:28 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-02 17:56:42 +0100 |
commit | 4de05faa8a85b5d6fd7304bab082c441b4a5afb2 (patch) | |
tree | 1be8c7f59b4270c08b95f3746dbb2469ccb4b066 | |
parent | 17639a42ae4e097e77c2de2e20984779ed69a739 (diff) | |
download | serenity-4de05faa8a85b5d6fd7304bab082c441b4a5afb2.zip |
LibJS: Add test cases for Intl.Locale.prototype.toString
Intl.Locale.prototype.toString wasn't testable before the constructor
was implemented.
-rw-r--r-- | Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.toString.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.toString.js b/Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.toString.js index caeac0c9ac..1fd946df01 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.toString.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.toString.js @@ -1,3 +1,28 @@ test("length is 0", () => { expect(Intl.Locale.prototype.toString).toHaveLength(0); }); + +test("normal behavior", () => { + const en1 = new Intl.Locale("en"); + expect(en1.toString()).toBe("en"); + + const en2 = new Intl.Locale("en-Latn"); + expect(en2.toString()).toBe("en-Latn"); + + const en3 = new Intl.Locale("en-US"); + expect(en3.toString()).toBe("en-US"); + + const en4 = new Intl.Locale("en", { language: "es" }); + expect(en4.toString()).toBe("es"); + + const en5 = new Intl.Locale("en", { script: "Latn" }); + expect(en5.toString()).toBe("en-Latn"); + + const en6 = new Intl.Locale("en", { script: "Latn", region: "US" }); + expect(en6.toString()).toBe("en-Latn-US"); +}); + +test("string is canonicalized behavior", () => { + const en = new Intl.Locale("EN", { script: "lAtN", region: "us" }); + expect(en.toString()).toBe("en-Latn-US"); +}); |