import { jsx as _jsx } from "react/jsx-runtime";
import { commonCryptoCurrencies } from '../../../ui/components/data-entry/currency-code-picker/defaults.js';
import { screen, waitFor } from '@testing-library/react';
import { renderWithForm } from '../../lib/testing.js';
import { AmountField } from './amount-field.js';
describe('AmountField Component', () => {
    it('should match snapshot', () => {
        const { container } = renderWithForm(_jsx(AmountField, { label: "Amount Label", name: "amount", type: "Amount", value: {
                value: 345,
            }, units: commonCryptoCurrencies }));
        expect(container).toMatchSnapshot();
    });
    it('should render label when provided', () => {
        renderWithForm(_jsx(AmountField, { label: "Amount Label", name: "amount", type: "Amount", value: {
                value: 345,
            }, units: commonCryptoCurrencies }));
        expect(screen.getByLabelText('Amount Label')).toBeInTheDocument();
    });
    it('should render error messages when provided', async () => {
        renderWithForm(_jsx(AmountField, { label: "Amount Label", name: "amount", type: "Amount", value: {
                value: 345,
            }, errors: ['Error 1', 'Error 2'], validators: () => 'Error 3', units: commonCryptoCurrencies }));
        await waitFor(() => {
            expect(screen.getByText('Error 1')).toBeInTheDocument();
            expect(screen.getByText('Error 2')).toBeInTheDocument();
            expect(screen.getByText('Error 3')).toBeInTheDocument();
        });
    });
    it('should render the percentage sign if the type is percent', () => {
        renderWithForm(_jsx(AmountField, { label: "Amount Label", name: "amount", type: "AmountPercentage", value: 345, step: 0 }));
        expect(screen.getByText('%')).toBeInTheDocument();
    });
    it('should disable the input when disabled prop is true', () => {
        renderWithForm(_jsx(AmountField, { label: "Amount Label", name: "amount", type: "Amount", value: {
                value: 345,
            }, units: commonCryptoCurrencies, disabled: true }));
        const input = screen.getByLabelText('Amount Label');
        expect(input).toBeDisabled();
    });
    it('should set the input as required when required prop is true', () => {
        renderWithForm(_jsx(AmountField, { label: "Amount Label", name: "amount", type: "Amount", value: {
                value: 345,
            }, required: true, units: commonCryptoCurrencies }));
        expect(screen.getByRole('spinbutton')).toHaveAttribute('required');
    });
    it('should render the description when provided', () => {
        renderWithForm(_jsx(AmountField, { label: "Amount Label", name: "amount", type: "Amount", value: {
                value: 345,
            }, units: commonCryptoCurrencies, disabled: true, description: "This is a description" }));
        expect(screen.getByText('This is a description')).toBeInTheDocument();
    });
});
//# sourceMappingURL=amount-field.test.js.map