import { render, screen } from "@testing-library/react"; import { caseStudies } from "@/lib/site-content"; import CasePage from "./page"; /** * Teste de caminhos-base de CasePage: os "fatos do projeto" no topo. * O teste principal cobre a lista ausente (`undefined`) e a lista preenchida; aqui, a lista vazia (`[]`). */ // usePathname: o HoverPrefetchLink (trilha, cartões) lê o caminho para saber se está na home jest.mock("next/navigation", () => ({ notFound: jest.fn(), usePathname: () => "/cases", })); function getCase(id: string) { const caseStudy = caseStudies.find((item) => item.id === id); if (!caseStudy) throw new Error(`Missing case ${id}`); return caseStudy; } describe("CasePage: fatos do projeto", () => { it("path: empty facts list -> no list in the hero, summary stays", async () => { const caseStudy = getCase("lavacao-047"); caseStudy.facts = []; try { const ui = await CasePage({ params: Promise.resolve({ slug: caseStudy.id }), }); render(ui); expect( screen.queryByRole("list", { name: "Fatos do projeto" }), ).toBeNull(); expect(screen.getByText(caseStudy.summary)).toBeVisible(); } finally { delete caseStudy.facts; } }); });