mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-15 15:26:59 +10:00
c66560ee12
Re-export isRTL from @reactive-resume/utils/locale in the web locale helper and consolidate RTL detection tests in the utils package. Co-authored-by: Cursor <cursoragent@cursor.com>
63 lines
1.3 KiB
TypeScript
63 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { defaultLocale, isLocale, isRTL } from "./locale";
|
|
|
|
describe("defaultLocale", () => {
|
|
it("is en-US", () => {
|
|
expect(defaultLocale).toBe("en-US");
|
|
});
|
|
});
|
|
|
|
describe("isLocale", () => {
|
|
it("returns true for non-empty string", () => {
|
|
expect(isLocale("en-US")).toBe(true);
|
|
});
|
|
|
|
it("returns false for unsupported locale string", () => {
|
|
expect(isLocale("xyz")).toBe(false);
|
|
});
|
|
|
|
it("returns false for empty string", () => {
|
|
expect(isLocale("")).toBe(false);
|
|
});
|
|
|
|
it("returns false for number", () => {
|
|
expect(isLocale(42)).toBe(false);
|
|
});
|
|
|
|
it("returns false for null", () => {
|
|
expect(isLocale(null)).toBe(false);
|
|
});
|
|
|
|
it("returns false for undefined", () => {
|
|
expect(isLocale(undefined)).toBe(false);
|
|
});
|
|
|
|
it("returns false for object", () => {
|
|
expect(isLocale({})).toBe(false);
|
|
});
|
|
|
|
it("returns false for array", () => {
|
|
expect(isLocale([])).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("isRTL", () => {
|
|
it.each([
|
|
["ar-SA", true],
|
|
["he-IL", true],
|
|
["fa-IR", true],
|
|
["ur-PK", true],
|
|
["en-US", false],
|
|
["en-GB", false],
|
|
["fr-FR", false],
|
|
["de-DE", false],
|
|
["zh-CN", false],
|
|
["xyz-XX", false],
|
|
["AR-SA", true],
|
|
["ar", true],
|
|
["en", false],
|
|
])("returns %s → %s", (locale, expected) => {
|
|
expect(isRTL(locale)).toBe(expected);
|
|
});
|
|
});
|