import * as React from 'react'; import { render } from '@testing-library/react'; import { FileUpload } from '.'; describe('FileUpload', () => { it('renders label from children', () => { const label = 'Label'; const { getByLabelText } = render({label}); expect(getByLabelText(label)).toBeInTheDocument(); }); it('shows a hint when one is provided', () => { const hint = 'hint'; const { getByText } = render(Label); expect(getByText(hint)).toBeInTheDocument(); }); it('does NOT show error when meta.touched is not true', () => { const error = 'error'; const { getByText } = render( Example ); expect(() => getByText(error)).toThrow(); }); it('shows error when meta.touched is true', () => { const error = 'error'; const { getByText } = render( Example ); expect(getByText(error)).toBeInTheDocument(); }); });