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
commit 21b3c5edba
Notes: sideshowbarker 2024-07-18 04:53:07 +09:00
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");
});
});