This commit is contained in:
+15
-1
@@ -1,8 +1,22 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { getLocalizedPathWithDefault } from "../lib/locale";
|
||||
import { FALLBACK_LOCALE, getLocalizedPathWithDefault, isSupportedLocale, resolveLocale } from "../lib/locale";
|
||||
|
||||
describe("locale path helpers", () => {
|
||||
it("recognizes supported locales explicitly", () => {
|
||||
expect(isSupportedLocale("ar")).toBe(true);
|
||||
expect(isSupportedLocale("en")).toBe(true);
|
||||
expect(isSupportedLocale("de")).toBe(true);
|
||||
expect(isSupportedLocale("fr")).toBe(false);
|
||||
expect(isSupportedLocale(undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it("resolves invalid locales with an explicit fallback", () => {
|
||||
expect(resolveLocale("ar", "de")).toBe("ar");
|
||||
expect(resolveLocale("fr", "en")).toBe("en");
|
||||
expect(resolveLocale("", FALLBACK_LOCALE)).toBe("de");
|
||||
});
|
||||
|
||||
it("keeps the configured default locale on the bare domain", () => {
|
||||
expect(getLocalizedPathWithDefault("ar", "/", "ar")).toBe("/");
|
||||
expect(getLocalizedPathWithDefault("de", "/", "ar")).toBe("/de");
|
||||
|
||||
Reference in New Issue
Block a user