"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 = __importDefault(require("react"));
const react_2 = require("@testing-library/react");
const TailwindInput_1 = require("../components/modern/TailwindInput");
describe('TailwindInput', () => {
    test('renders correctly with default props', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input" }));
        const input = react_2.screen.getByRole('textbox');
        expect(input).toBeInTheDocument();
        expect(input).toHaveAttribute('name', 'test-input');
        expect(input).toHaveAttribute('type', 'text');
    });
    test('renders with label and required indicator', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", label: "Test Label", isRequired: true }));
        const label = react_2.screen.getByText('Test Label');
        expect(label).toBeInTheDocument();
        const requiredIndicator = react_2.screen.getByText('*');
        expect(requiredIndicator).toBeInTheDocument();
        expect(requiredIndicator).toHaveClass('text-red-500');
    });
    test('renders with placeholder text', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", placeholder: "Enter text here" }));
        const input = react_2.screen.getByPlaceholderText('Enter text here');
        expect(input).toBeInTheDocument();
    });
    test('renders helper text when provided', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", helperText: "This is a helper text" }));
        const helperText = react_2.screen.getByText('This is a helper text');
        expect(helperText).toBeInTheDocument();
        expect(helperText).toHaveClass('text-gray-500');
    });
    test('renders error message when provided', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", error: "This field is required" }));
        const errorMessage = react_2.screen.getByText('This field is required');
        expect(errorMessage).toBeInTheDocument();
        expect(errorMessage).toHaveClass('text-red-500');
        const input = react_2.screen.getByRole('textbox');
        expect(input).toHaveAttribute('aria-invalid', 'true');
    });
    test('handles user input correctly', () => {
        const handleChange = jest.fn();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", onChange: handleChange }));
        const input = react_2.screen.getByRole('textbox');
        react_2.fireEvent.change(input, { target: { value: 'test value' } });
        expect(handleChange).toHaveBeenCalledTimes(1);
        expect(input).toHaveValue('test value');
    });
    test('applies disabled state correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", isDisabled: true }));
        const input = react_2.screen.getByRole('textbox');
        expect(input).toBeDisabled();
        expect(input).toHaveClass('disabled:opacity-50');
    });
    test('applies readonly state correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", isReadOnly: true }));
        const input = react_2.screen.getByRole('textbox');
        expect(input).toHaveAttribute('readonly');
    });
    test('renders with different input types', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "email-input", type: "email", "data-testid": "email-input" }));
        const emailInput = react_2.screen.getByTestId('email-input');
        expect(emailInput).toHaveAttribute('type', 'email');
    });
    test('applies different sizes correctly', () => {
        const { rerender } = (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", size: "sm", "data-testid": "test-input" }));
        let input = react_2.screen.getByTestId('test-input');
        expect(input).toHaveClass('h-8');
        rerender((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", size: "md", "data-testid": "test-input" }));
        input = react_2.screen.getByTestId('test-input');
        expect(input).toHaveClass('h-10');
        rerender((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", size: "lg", "data-testid": "test-input" }));
        input = react_2.screen.getByTestId('test-input');
        expect(input).toHaveClass('h-12');
    });
    test('renders with icon on the left', () => {
        const iconTestId = 'test-icon';
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", icon: (0, jsx_runtime_1.jsx)("div", { "data-testid": iconTestId, children: "\uD83D\uDD0D" }), iconPosition: "left" }));
        const icon = react_2.screen.getByTestId(iconTestId);
        expect(icon).toBeInTheDocument();
        const input = react_2.screen.getByRole('textbox');
        expect(input).toHaveClass('pl-10');
    });
    test('renders with icon on the right', () => {
        const iconTestId = 'test-icon';
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", icon: (0, jsx_runtime_1.jsx)("div", { "data-testid": iconTestId, children: "\uD83D\uDD0D" }), iconPosition: "right" }));
        const icon = react_2.screen.getByTestId(iconTestId);
        expect(icon).toBeInTheDocument();
        const input = react_2.screen.getByRole('textbox');
        expect(input).toHaveClass('pr-10');
    });
    test('renders with adornment', () => {
        const adornmentTestId = 'test-adornment';
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", adornment: (0, jsx_runtime_1.jsx)("div", { "data-testid": adornmentTestId, children: "USD" }), adornmentPosition: "right" }));
        const adornment = react_2.screen.getByTestId(adornmentTestId);
        expect(adornment).toBeInTheDocument();
        const input = react_2.screen.getByRole('textbox');
        expect(input).toHaveClass('pr-12');
    });
    test('applies additional class names correctly', () => {
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", containerClassName: "test-container-class", inputClassName: "test-input-class", labelClassName: "test-label-class", label: "Test Label" }));
        const container = react_2.screen.getByRole('textbox').parentElement?.parentElement;
        expect(container).toHaveClass('test-container-class');
        const input = react_2.screen.getByRole('textbox');
        expect(input).toHaveClass('test-input-class');
        const label = react_2.screen.getByText('Test Label');
        expect(label).toHaveClass('test-label-class');
    });
    test('forwards ref to input element', () => {
        const ref = react_1.default.createRef();
        (0, react_2.render)((0, jsx_runtime_1.jsx)(TailwindInput_1.TailwindInput, { name: "test-input", ref: ref }));
        expect(ref.current).not.toBeNull();
        expect(ref.current?.tagName).toBe('INPUT');
    });
});
//# sourceMappingURL=TailwindInput.test.js.map