import { render, screen, testA11y } from '@fuels/jest'; import { Button } from '../Button'; import { Input } from './Input'; const FIELD_ARGS = { type: 'text', name: 'name', placeholder: 'Type your name', }; describe('Input', () => { it('a11y', async () => { await testA11y( , ); }); it('should render an input field correctly', () => { const { container } = render( , ); expect(container.querySelector('input')).toBeInTheDocument(); expect(screen.getByRole('textbox')).toBeInTheDocument(); }); it('should render addons correctly', () => { render( https:// .com , ); expect(screen.getByRole('textbox')).toBeInTheDocument(); expect(screen.getByText('https://')).toBeInTheDocument(); expect(screen.getByText('.com')).toBeInTheDocument(); }); it('should render invalid input correctly', () => { render( , ); expect(screen.getByRole('textbox')).toHaveAttribute('aria-invalid', 'true'); }); it('should render disabled input correctly', () => { render( , ); expect(screen.getByRole('textbox')).toHaveAttribute( 'aria-disabled', 'true', ); }); it('should render readonly input correctly', () => { render( , ); expect(screen.getByRole('textbox')).toHaveAttribute( 'aria-readonly', 'true', ); }); it('should render input amount correctly', () => { render( , ); expect(screen.getByRole('textbox')).toHaveAttribute('inputmode', 'numeric'); }); it('should render elements using element prop', async () => { render( Click} /> , ); expect(screen.getByRole('button')).toBeInTheDocument(); }); it("should don't call elements if disabled", async () => { render( , ); expect(screen.getByRole('button')).toHaveAttribute('aria-disabled', 'true'); }); it("should don't call elements if readonly", async () => { render( , ); expect(screen.getByRole('button')).toHaveAttribute('aria-disabled', 'true'); }); it('should focus correctly when have button inside element', async () => { const { user } = render( , ); await user.tab(); expect(screen.getByRole('textbox')).toHaveFocus(); await user.tab(); expect(screen.getByRole('button')).toHaveFocus(); }); });