1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:37:35 +00:00

LibJS: Implement Intl.Locale.prototype.baseName

This commit is contained in:
Timothy Flynn 2021-09-01 22:39:40 -04:00 committed by Linus Groh
parent 27fc3cfe75
commit 21b3c5edba
4 changed files with 44 additions and 0 deletions

View file

@ -0,0 +1,21 @@
describe("errors", () => {
test("called on non-Locale object", () => {
expect(() => {
Intl.Locale.prototype.baseName;
}).toThrowWithMessage(TypeError, "Not a Intl.Locale object");
});
});
describe("normal behavior", () => {
test("basic functionality", () => {
expect(new Intl.Locale("en").baseName).toBe("en");
expect(new Intl.Locale("en-Latn").baseName).toBe("en-Latn");
expect(new Intl.Locale("en-GB").baseName).toBe("en-GB");
expect(new Intl.Locale("en", { script: "Latn" }).baseName).toBe("en-Latn");
expect(new Intl.Locale("en", { region: "GB" }).baseName).toBe("en-GB");
expect(new Intl.Locale("en-u-ca-abc").baseName).toBe("en");
expect(new Intl.Locale("en", { calendar: "abc" }).baseName).toBe("en");
expect(new Intl.Locale("en-x-abcd").baseName).toBe("en");
});
});