import { describe, expect, it } from "@suaveplan/testing/runner"; import { LOCALE_BCP47_MAP } from "./locale-bcp47-map.js"; describe("LOCALE_BCP47_MAP", () => { it("short code en maps to en-GB", { timeout: 5000 }, () => { expect(LOCALE_BCP47_MAP["en"]).toBe("en-GB"); }); it("mixed-case zh-cn maps to zh-CN", { timeout: 5000 }, () => { expect(LOCALE_BCP47_MAP["zh-cn"]).toBe("zh-CN"); }); it("short code zh maps to zh-CN", { timeout: 5000 }, () => { expect(LOCALE_BCP47_MAP["zh"]).toBe("zh-CN"); }); it("pt-br maps to pt-BR", { timeout: 5000 }, () => { expect(LOCALE_BCP47_MAP["pt-br"]).toBe("pt-BR"); }); it("RTL languages map to canonical region tags", { timeout: 5000 }, () => { expect(LOCALE_BCP47_MAP["ar"]).toBe("ar-SA"); expect(LOCALE_BCP47_MAP["he"]).toBe("he-IL"); expect(LOCALE_BCP47_MAP["fa"]).toBe("fa-IR"); }); it("returns undefined for unknown codes (consumer handles miss)", { timeout: 5000, }, () => { expect(LOCALE_BCP47_MAP["xx-yy"]).toBeUndefined(); expect(LOCALE_BCP47_MAP["klingon"]).toBeUndefined(); }); it("every value follows the BCP-47 lang-REGION shape", { timeout: 5000, }, () => { const bcp47Pattern = /^[a-z]{2,3}-[A-Z]{2}$/; for (const value of Object.values(LOCALE_BCP47_MAP)) { expect(value).toMatch(bcp47Pattern); } }); it("every key is lowercase", { timeout: 5000 }, () => { for (const key of Object.keys(LOCALE_BCP47_MAP)) { expect(key).toBe(key.toLowerCase()); } }); it("contains the documented 22 entries", { timeout: 5000 }, () => { expect(Object.keys(LOCALE_BCP47_MAP)).toHaveLength(22); }); });