import { describe, expect, it } from "vitest"; import { getLocalizedValue, resolvePortfolioProjectViewMode } from "@/lib/portfolio"; describe("resolvePortfolioProjectViewMode", () => { it("keeps supported view modes", () => { expect(resolvePortfolioProjectViewMode("GRID")).toBe("GRID"); expect(resolvePortfolioProjectViewMode("STORY")).toBe("STORY"); expect(resolvePortfolioProjectViewMode("CASE_STUDY")).toBe("CASE_STUDY"); }); it("falls back to GRID for unknown or missing values", () => { expect(resolvePortfolioProjectViewMode(undefined)).toBe("GRID"); expect(resolvePortfolioProjectViewMode(null)).toBe("GRID"); expect(resolvePortfolioProjectViewMode("unexpected")).toBe("GRID"); }); }); describe("getLocalizedValue", () => { const content = { ar: "عربي", en: "English", de: "Deutsch" }; it("returns the direct locale value when present", () => { expect(getLocalizedValue(content, "en")).toBe("English"); expect(getLocalizedValue(content, "ar")).toBe("عربي"); }); it("falls back to the provided fallback locale", () => { expect(getLocalizedValue({ ar: "", en: "", de: "Deutsch" }, "en", "de")).toBe("Deutsch"); }); it("falls back to any available value when neither locale is filled", () => { expect(getLocalizedValue({ ar: "عربي", en: "", de: "" }, "en", "de")).toBe("عربي"); }); it("trims whitespace-only values before considering them empty", () => { expect(getLocalizedValue({ ar: " ", en: " ", de: "Deutsch" }, "en", "de")).toBe("Deutsch"); }); it("returns an empty string when everything is blank", () => { expect(getLocalizedValue({ ar: "", en: "", de: "" }, "en")).toBe(""); }); });