import { describe, it, expect } from "vitest"; import { render, screen } from "@testing-library/react"; import { PoStatusBadge } from "@/components/po/po-status-badge"; import { PO_STATUS_LABELS } from "@/lib/utils"; import type { POStatus } from "@prisma/client"; const ALL_STATUSES: POStatus[] = [ "DRAFT", "SUBMITTED", "MGR_REVIEW", "VENDOR_ID_PENDING", "EDITS_REQUESTED", "REJECTED", "MGR_APPROVED", "SENT_FOR_PAYMENT", "PAID_DELIVERED", "CLOSED", ]; describe("PoStatusBadge", () => { it.each(ALL_STATUSES)("renders the correct label for %s", (status) => { render(); expect(screen.getByText(PO_STATUS_LABELS[status])).toBeInTheDocument(); }); it("renders 'Draft' for DRAFT status", () => { render(); expect(screen.getByText("Draft")).toBeInTheDocument(); }); it("renders 'Approved' for MGR_APPROVED status", () => { render(); expect(screen.getByText("Approved")).toBeInTheDocument(); }); it("renders 'Rejected' for REJECTED status", () => { render(); expect(screen.getByText("Rejected")).toBeInTheDocument(); }); it("renders 'Under Review' for MGR_REVIEW status", () => { render(); expect(screen.getByText("Under Review")).toBeInTheDocument(); }); it("renders 'Edits Requested' for EDITS_REQUESTED status", () => { render(); expect(screen.getByText("Edits Requested")).toBeInTheDocument(); }); it("renders 'Vendor ID Pending' for VENDOR_ID_PENDING status", () => { render(); expect(screen.getByText("Vendor ID Pending")).toBeInTheDocument(); }); it("renders exactly one badge element", () => { const { container } = render(); // Badge renders as a single span/div-like element expect(container.firstChild).not.toBeNull(); expect(container.children).toHaveLength(1); }); });