// packages/nextjs-jsonapi/src/shadcnui/ui/__tests__/confirm-dialog.test.tsx
import { describe, expect, it, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { ConfirmDialog } from "../confirm-dialog";
describe("ConfirmDialog", () => {
it("renders title/description and calls onConfirm then closes", async () => {
const onConfirm = vi.fn();
const onOpenChange = vi.fn();
render(
,
);
expect(screen.getByText("Reveal plot secrets?")).toBeInTheDocument();
expect(screen.getByText("Spoilers ahead.")).toBeInTheDocument();
await userEvent.click(screen.getByRole("button", { name: "Reveal" }));
expect(onConfirm).toHaveBeenCalledTimes(1);
expect(onOpenChange).toHaveBeenCalledWith(false);
});
it("cancel closes without confirming", async () => {
const onConfirm = vi.fn();
const onOpenChange = vi.fn();
render(
,
);
await userEvent.click(screen.getByRole("button", { name: "No" }));
expect(onConfirm).not.toHaveBeenCalled();
});
});