VerticalCard.test.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import type { Vertical } from "@/types";
  2. import { render, screen } from "@testing-library/react";
  3. import { describe, expect, it } from "vitest";
  4. import { VerticalCard } from "./VerticalCard";
  5. const mockVertical: Vertical = {
  6. slug: "honey-bees",
  7. title: "Honey Bees",
  8. summary: "Fresh local honey",
  9. image: "/images/honey-bees.jpg",
  10. description: "Details here.",
  11. pillars: ["body"],
  12. status: "active",
  13. };
  14. describe("VerticalCard", () => {
  15. it("renders title and summary in grid variant (default)", () => {
  16. render(<VerticalCard vertical={mockVertical} />);
  17. expect(screen.getByText("Honey Bees")).toBeInTheDocument();
  18. expect(screen.getByText("Fresh local honey")).toBeInTheDocument();
  19. });
  20. it("renders status badge text", () => {
  21. render(<VerticalCard vertical={mockVertical} />);
  22. // status is rendered as "active" -> "active"
  23. expect(screen.getByText("active")).toBeInTheDocument();
  24. });
  25. it("links to the correct offering page", () => {
  26. render(<VerticalCard vertical={mockVertical} />);
  27. const link = screen.getByRole("link");
  28. expect(link).toHaveAttribute("href", "/offerings/honey-bees");
  29. });
  30. it("renders feature variant without crashing", () => {
  31. render(<VerticalCard vertical={mockVertical} variant="feature" />);
  32. expect(screen.getByText("Honey Bees")).toBeInTheDocument();
  33. });
  34. });