"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("@testing-library/react");
const user_event_1 = __importDefault(require("@testing-library/user-event"));
const TailwindCard_1 = require("../TailwindCard");
describe('TailwindCard Component', () => {
    test('renders with minimal props', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { children: "Card Content" }));
        const card = react_1.screen.getByText('Card Content');
        expect(card).toBeInTheDocument();
    });
    test('renders with title', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { title: "Card Title", children: "Card Content" }));
        const title = react_1.screen.getByText('Card Title');
        expect(title).toBeInTheDocument();
        expect(title.tagName).toBe('H3');
    });
    test('renders with image', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { title: "Card Title", image: "https://example.com/image.jpg", children: "Card Content" }));
        const image = react_1.screen.getByAltText('Card Title');
        expect(image).toBeInTheDocument();
        expect(image.tagName).toBe('IMG');
        expect(image).toHaveAttribute('src', 'https://example.com/image.jpg');
    });
    test('renders with footer', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { title: "Card Title", footer: (0, jsx_runtime_1.jsx)("button", { children: "Action" }), children: "Card Content" }));
        const footer = react_1.screen.getByText('Action');
        expect(footer).toBeInTheDocument();
        expect(footer.tagName).toBe('BUTTON');
    });
    test('handles click events when clickable', async () => {
        const handleClick = jest.fn();
        const user = user_event_1.default.setup();
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { clickable: true, onClick: handleClick, children: "Clickable Card" }));
        const card = react_1.screen.getByText('Clickable Card').closest('div');
        expect(card).toHaveClass('cursor-pointer');
        await user.click(card);
        expect(handleClick).toHaveBeenCalledTimes(1);
    });
    test('renders with URL as anchor tag', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { url: "https://example.com", children: "Link Card" }));
        const card = react_1.screen.getByText('Link Card').closest('a');
        expect(card).toHaveAttribute('href', 'https://example.com');
    });
    test('applies variant styles', () => {
        const { rerender } = (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { variant: "default", children: "Default Card" }));
        const defaultCard = react_1.screen.getByText('Default Card').closest('div');
        expect(defaultCard).toHaveClass('bg-card');
        rerender((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { variant: "elevated", children: "Elevated Card" }));
        const elevatedCard = react_1.screen.getByText('Elevated Card').closest('div');
        expect(elevatedCard).toHaveClass('shadow-lg');
        rerender((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { variant: "outlined", children: "Outlined Card" }));
        const outlinedCard = react_1.screen.getByText('Outlined Card').closest('div');
        expect(outlinedCard).toHaveClass('border');
    });
    test('applies size styles', () => {
        const { rerender } = (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { size: "small", children: "Small Card" }));
        const smallCard = react_1.screen.getByText('Small Card').closest('div');
        expect(smallCard).toHaveClass('p-3');
        rerender((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { size: "medium", children: "Medium Card" }));
        const mediumCard = react_1.screen.getByText('Medium Card').closest('div');
        expect(mediumCard).toHaveClass('p-5');
        rerender((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { size: "large", children: "Large Card" }));
        const largeCard = react_1.screen.getByText('Large Card').closest('div');
        expect(largeCard).toHaveClass('p-7');
    });
    test('applies hoverable styles', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { hoverable: true, children: "Hoverable Card" }));
        const card = react_1.screen.getByText('Hoverable Card').closest('div');
        expect(card).toHaveClass('hover:shadow-md');
    });
    test('applies custom class names', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { className: "custom-class", children: "Custom Class Card" }));
        const card = react_1.screen.getByText('Custom Class Card').closest('div');
        expect(card).toHaveClass('custom-class');
    });
    test('forwards additional props to the card element', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { "data-testid": "test-card", "aria-label": "Test Card", children: "Test Card" }));
        const card = react_1.screen.getByTestId('test-card');
        expect(card).toHaveAttribute('aria-label', 'Test Card');
    });
    test('renders content from content prop', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { content: "Content Prop Text" }));
        const content = react_1.screen.getByText('Content Prop Text');
        expect(content).toBeInTheDocument();
    });
    test('prioritizes children over content prop', () => {
        (0, react_1.render)((0, jsx_runtime_1.jsx)(TailwindCard_1.TailwindCard, { content: "Content Prop Text", children: "Children Text" }));
        expect(react_1.screen.getByText('Children Text')).toBeInTheDocument();
        expect(react_1.screen.queryByText('Content Prop Text')).not.toBeInTheDocument();
    });
});
//# sourceMappingURL=TailwindCard.test.js.map