Files
lunch/tests/locale.test.ts
kai a62e48116a
release / which version (push) Successful in 3s
release / olares chart · sanity (push) Successful in 3s
release / app (push) Successful in 55s
release / tag and release (push) Successful in 3s
Scaffold app, chart, CI and release (26.11.1) (#2)
2026-11-06 19:14:55 +00:00

22 lines
765 B
TypeScript

import { describe, expect, it } from "vitest";
import { negotiateLocale, resolveLocale } from "@/lib/locale";
describe("negotiateLocale", () => {
it("falls back to German", () => {
expect(negotiateLocale(null)).toBe("de");
expect(negotiateLocale("ja,zh;q=0.8")).toBe("de");
});
it("respects quality values and region tags", () => {
expect(negotiateLocale("fr-CH, fr;q=0.9, en;q=0.8")).toBe("fr");
expect(negotiateLocale("it;q=1, es-ES;q=0.7, en;q=0.9")).toBe("en");
expect(negotiateLocale("en;q=0, es")).toBe("es");
});
});
describe("resolveLocale", () => {
it("prefers the person's choice over the browser", () => {
expect(resolveLocale("es", "de-DE")).toBe("es");
expect(resolveLocale("xx", "en-GB")).toBe("en");
});
});