Files
sass-mohfarawati/tests/locale.test.ts
T
MOH 27df4ad2fe
CI / quality (push) Waiting to run
Unify dynamic locale routing
2026-03-15 05:12:33 +01:00

23 lines
1.0 KiB
TypeScript

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");
});
});