import { describe, expect, it } from "vitest"; import { getLocalizedPathWithDefault } from "../lib/locale"; describe("locale path helpers", () => { it("keeps the configured default locale on the bare domain", () => { expect(getLocalizedPathWithDefault("ar", "/", "ar")).toBe("/"); expect(getLocalizedPathWithDefault("de", "/", "ar")).toBe("/de"); expect(getLocalizedPathWithDefault("en", "/", "ar")).toBe("/en"); }); it("builds nested paths against the configured default locale", () => { expect(getLocalizedPathWithDefault("ar", "/coming-soon", "ar")).toBe("/coming-soon"); expect(getLocalizedPathWithDefault("de", "/coming-soon", "ar")).toBe("/de/coming-soon"); expect(getLocalizedPathWithDefault("en", "/portfolio", "de")).toBe("/en/portfolio"); }); it("strips old locale prefixes before rebuilding the target path", () => { expect(getLocalizedPathWithDefault("en", "/ar/contact", "de")).toBe("/en/contact"); expect(getLocalizedPathWithDefault("ar", "/de/about", "ar")).toBe("/about"); }); });