import { describe, it, expect, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { DialogFooter } from "../DialogFooter";
describe("DialogFooter", () => {
it("renders cancel/confirm labels and wires both callbacks", async () => {
const onCancel = vi.fn();
const onConfirm = vi.fn();
render(
,
);
await userEvent.click(screen.getByRole("button", { name: "Cancel" }));
expect(onCancel).toHaveBeenCalledTimes(1);
await userEvent.click(screen.getByRole("button", { name: "Save" }));
expect(onConfirm).toHaveBeenCalledTimes(1);
});
it("prefers the busy label and maps confirmColor=error to destructive", () => {
render(
{}}
onConfirm={() => {}}
confirmLabel="Delete"
confirmBusyLabel="Deleting…"
confirmColor="error"
/>,
);
const confirm = screen.getByRole("button", { name: "Deleting…" });
expect(confirm).toBeInTheDocument();
expect(confirm.getAttribute("data-variant")).toBe("destructive");
});
it("renders the secondary action when provided", () => {
render(
{}}
onConfirm={() => {}}
confirmLabel="OK"
secondaryAction={}
/>,
);
expect(
screen.getByRole("button", { name: "Test SSH" }),
).toBeInTheDocument();
});
});