import { FileUploadField } from '../FileUploadField'; import { render, screen } from '@testing-library/react'; import '@testing-library/jest-dom'; test('simple fileuploadfield', () => { const browserBtnClickHandler = jest.fn(); const clearBtnClickHandler = jest.fn(); const { asFragment } = render( {A custom preview of the uploaded file can be passed as children} ); expect(asFragment()).toMatchSnapshot(); }); test('Renders without aria-describedby on browse button by default', () => { render(); expect(screen.getByRole('button', { name: 'Upload' })).not.toHaveAccessibleDescription(); }); test('Renders with aria-describedby on browse button', () => { render( Helper text ); expect(screen.getByRole('button', { name: 'Upload' })).toHaveAccessibleDescription('Helper text'); }); test('Browse button is enabled by default', () => { render(); expect(screen.getByRole('button', { name: 'Upload' })).not.toHaveAttribute('disabled'); }); test('Browse button is disabled with isBrowseButtonDisabled prop', () => { render(); expect(screen.getByRole('button', { name: 'Upload' })).toHaveAttribute('disabled'); });
A custom preview of the uploaded file can be passed as children