import { jsx as _jsx } from "react/jsx-runtime";
import { render, screen } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import { describe, expect, it, vi } from 'vitest';
import { Button } from './button.js';
describe('Button', () => {
    it('should match snapshot', () => {
        const { container } = render(_jsx(Button, { children: "Click me" }));
        expect(container).toMatchSnapshot();
    });
    it('should render a button element', () => {
        render(_jsx(Button, { children: "Click me" }));
        expect(screen.getByRole('button')).toBeInTheDocument();
    });
    it('should be disabled when disabled prop is true', () => {
        render(_jsx(Button, { disabled: true, children: "Disabled Button" }));
        expect(screen.getByRole('button')).toBeDisabled();
    });
    it('should call onClick when clicked', async () => {
        const user = userEvent.setup();
        const handleClick = vi.fn();
        render(_jsx(Button, { onClick: handleClick, children: "Click me" }));
        await user.click(screen.getByRole('button'));
        expect(handleClick).toHaveBeenCalledTimes(1);
    });
    it('should not call onClick when disabled', async () => {
        const user = userEvent.setup();
        const handleClick = vi.fn();
        render(_jsx(Button, { onClick: handleClick, disabled: true, children: "Disabled Button" }));
        await user.click(screen.getByRole('button'));
        expect(handleClick).not.toHaveBeenCalled();
    });
    it('should apply custom className', () => {
        render(_jsx(Button, { className: "custom-class", children: "Button" }));
        expect(screen.getByRole('button')).toHaveClass('custom-class');
    });
    it('should render as child element when asChild is true', () => {
        render(_jsx(Button, { asChild: true, children: _jsx("a", { href: "/test", children: "Link Button" }) }));
        const link = screen.getByRole('link');
        expect(link).toBeInTheDocument();
        expect(link).toHaveAttribute('href', '/test');
        expect(link).toHaveClass('inline-flex');
        expect(link).toHaveClass('items-center');
    });
    it('should preserve all button attributes', () => {
        render(_jsx(Button, { type: "submit", form: "test-form", "data-testid": "test-button", children: "Submit" }));
        const button = screen.getByRole('button');
        expect(button).toHaveAttribute('type', 'submit');
        expect(button).toHaveAttribute('form', 'test-form');
        expect(button).toHaveAttribute('data-testid', 'test-button');
    });
    it('should support keyboard navigation', async () => {
        const user = userEvent.setup();
        const handleClick = vi.fn();
        render(_jsx(Button, { onClick: handleClick, children: "Keyboard Button" }));
        const button = screen.getByRole('button');
        button.focus();
        expect(button).toHaveFocus();
        await user.keyboard('{Enter}');
        expect(handleClick).toHaveBeenCalledTimes(1);
        await user.keyboard(' ');
        expect(handleClick).toHaveBeenCalledTimes(2);
    });
    it('should have focus-visible styles', () => {
        render(_jsx(Button, { children: "Focus Button" }));
        const button = screen.getByRole('button');
        expect(button).toHaveClass('focus-visible:border-ring');
        expect(button).toHaveClass('focus-visible:ring-ring/50');
    });
});
//# sourceMappingURL=button.test.js.map