1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 11:47:46 +00:00

LibJS: Implement Intl.Locale.prototype.textInfo property

This commit is contained in:
Timothy Flynn 2022-07-05 19:50:24 -04:00 committed by Linus Groh
parent 4868b888be
commit 88a560dd84
6 changed files with 70 additions and 0 deletions

View file

@ -0,0 +1,26 @@
describe("errors", () => {
test("called on non-Locale object", () => {
expect(() => {
Intl.Locale.prototype.textInfo;
}).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
});
});
describe("normal behavior", () => {
test("basic functionality", () => {
const textInfo = new Intl.Locale("en").textInfo;
expect(textInfo).toBeDefined();
expect(Object.getPrototypeOf(textInfo)).toBe(Object.prototype);
expect(textInfo.direction).toBeDefined();
expect(Object.getPrototypeOf(textInfo.direction)).toBe(String.prototype);
expect(textInfo.direction).toBe("ltr");
expect(new Intl.Locale("ar").textInfo.direction).toBe("rtl");
});
test("fallback to ltr", () => {
expect(new Intl.Locale("xx").textInfo.direction).toBe("ltr");
});
});