import { describe, expect, it } from "vitest"; import { render, screen } from "@testing-library/react"; import { Button } from "@/components/ui/Button"; import { TestimonialSlider } from "@/components/sections/TestimonialSlider"; import { buildSpiral } from "@/lib/spiral"; describe("Button", () => { it("rend un lien quand href est fourni", () => { render(); expect(screen.getByRole("link", { name: /voir/i })).toHaveAttribute("href", "/services"); }); it("rend un bouton sinon", () => { render(); expect(screen.getByRole("button", { name: "OK" })).toHaveAttribute("type", "button"); }); }); describe("TestimonialSlider", () => { const items = [ { quote: "Un", author: "A", role: "r1" }, { quote: "Deux", author: "B", role: "r2" }, ]; it("affiche le premier témoignage et la pagination accessible", () => { render(); expect(screen.getByText("Un")).toBeInTheDocument(); expect(screen.getByRole("button", { name: "Témoignage 2 sur 2" })).toBeInTheDocument(); expect(screen.getByRole("button", { name: /pause/i })).toBeInTheDocument(); }); it("n'affiche pas de pagination avec un seul avis", () => { render(); expect(screen.queryByRole("group")).toBeNull(); }); }); describe("spirale de Fibonacci", () => { it("produit des carrés de côtés de Fibonacci et un rectangle 34×21 à 8 niveaux", () => { const { squares, bbox, path } = buildSpiral(8); expect(squares.map((s) => s.s)).toEqual([1, 1, 2, 3, 5, 8, 13, 21]); expect([bbox.w, bbox.h].sort((a, b) => a - b)).toEqual([21, 34]); expect(path.startsWith("M ")).toBe(true); expect((path.match(/A /g) ?? []).length).toBe(8); }); });