spb/phi-conseil
Public
1import { describe, expect, it } from "vitest";2import {3 site,4 home,5 pages,6 homeSchema,7 displayableTestimonials,8 serviceBySlug,9} from "@/lib/content";1011describe("contenu administrable", () => {12 it("charge et valide les trois fichiers JSON", () => {13 expect(site.brand.name).toBe("PHI Conseil");14 expect(home.services.items).toHaveLength(4);15 expect(pages.contact.subjects.length).toBeGreaterThan(0);16 });1718 it("rejette un contenu invalide avec un message lisible", () => {19 const broken = structuredClone(home) as Record<string, unknown>;20 (broken.hero as { titleLines: string[] }).titleLines = [];21 const r = homeSchema.safeParse(broken);22 expect(r.success).toBe(false);23 });2425 it("ne publie jamais un témoignage non approuvé hors prévisualisation", () => {26 expect(displayableTestimonials(false).items).toHaveLength(0);27 });2829 it("montre les exemples en prévisualisation avec le drapeau isPreview", () => {30 const r = displayableTestimonials(true);31 expect(r.isPreview).toBe(true);32 expect(r.items.length).toBeGreaterThan(0);33 });3435 it("retrouve un service par slug", () => {36 expect(serviceBySlug("reddition-de-comptes")?.title).toBe("Reddition de comptes");37 expect(serviceBySlug("inexistant")).toBeUndefined();38 });39});40