import { describe, it, expect } from "vitest"; import { DIAL_CODES, PINNED, flagEmoji } from "./dialCodes"; describe("dialCodes dataset", () => { it("includes Malaysia (+60) and Singapore (+65)", () => { const my = DIAL_CODES.find(d => d.iso2 === "MY"); const sg = DIAL_CODES.find(d => d.iso2 === "SG"); expect(my?.dialCode).toBe("+60"); expect(sg?.dialCode).toBe("+65"); }); it("has no duplicate iso2 codes", () => { const seen = new Set(); for (const d of DIAL_CODES) { expect(seen.has(d.iso2)).toBe(false); seen.add(d.iso2); } }); it("every entry has a non-empty name and dialCode starting with +", () => { for (const d of DIAL_CODES) { expect(d.name.trim().length).toBeGreaterThan(0); expect(d.dialCode.startsWith("+")).toBe(true); } }); it("every entry has a 2-letter iso2 and a digit-only dial code", () => { for (const d of DIAL_CODES) { expect(d.iso2).toMatch(/^[A-Z]{2}$/); expect(d.dialCode).toMatch(/^\+\d+$/); } }); it("pins Malaysia and Singapore", () => { expect(PINNED).toEqual(["MY", "SG"]); }); it("derives the flag emoji from the iso2 code", () => { expect(flagEmoji("MY")).toBe("πŸ‡²πŸ‡Ύ"); expect(flagEmoji("SG")).toBe("πŸ‡ΈπŸ‡¬"); }); it("is a sizable international list", () => { expect(DIAL_CODES.length).toBeGreaterThan(150); }); });