import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { CustomModal } from "./CustomModal"; describe("CustomModal", () => { const mockOnClose = vi.fn(); beforeEach(() => { vi.clearAllMocks(); }); it("renders without crashing when open", () => { render(
Test Content
); expect(screen.getByText("Test Modal")).toBeInTheDocument(); }); it("does not render when closed", () => { render(
Test Content
); expect(screen.queryByText("Test Modal")).not.toBeInTheDocument(); }); it("displays the title", () => { render(
Test Content
); expect(screen.getByText("Test Modal Title")).toBeInTheDocument(); }); it("renders children content", () => { render(
Custom Modal Content
); expect(screen.getByText("Custom Modal Content")).toBeInTheDocument(); }); it("applies sm width prop", () => { render(
Test Content
); expect(screen.getByText("Test Modal")).toBeInTheDocument(); }); it("renders with md width by default", () => { render(
Test Content
); expect(screen.getByText("Test Modal")).toBeInTheDocument(); }); it("applies lg width prop", () => { render(
Test Content
); expect(screen.getByText("Test Modal")).toBeInTheDocument(); }); it("applies xl width prop", () => { render(
Test Content
); expect(screen.getByText("Test Modal")).toBeInTheDocument(); }); it("applies 2xl width prop", () => { render(
Test Content
); expect(screen.getByText("Test Modal")).toBeInTheDocument(); }); it("applies full width prop", () => { render(
Test Content
); expect(screen.getByText("Test Modal")).toBeInTheDocument(); }); it("applies auto width prop", () => { render(
Test Content
); expect(screen.getByText("Test Modal")).toBeInTheDocument(); }); });