diff --git a/webpack/assets/javascripts/react_app/components/common/forms/Form.test.js b/webpack/assets/javascripts/react_app/components/common/forms/Form.test.js index 7e119ef570..1ef0f0dcd2 100644 --- a/webpack/assets/javascripts/react_app/components/common/forms/Form.test.js +++ b/webpack/assets/javascripts/react_app/components/common/forms/Form.test.js @@ -1,23 +1,29 @@ -import { shallow } from 'enzyme'; import React from 'react'; +import { render, screen } from '@testing-library/react'; +import '@testing-library/jest-dom'; import Form from './Form'; describe('Form', () => { - it('should render a form', () => { - const wrapper = shallow(
); + it('renders a form without an error alert', () => { + const { container } = render(); - expect(wrapper).toMatchSnapshot(); + expect(container.querySelector('form.form-horizontal')).toBeInTheDocument(); + expect(container.querySelector('.alert')).not.toBeInTheDocument(); }); - it('should display one base error', () => { - const wrapper = shallow( + + it('displays one base error with the default title', () => { + const { container } = render( ); - expect(wrapper).toMatchSnapshot(); + expect(container.querySelector('.alert-danger')).toBeInTheDocument(); + expect(screen.getByText('Unable to save.')).toBeInTheDocument(); + expect(screen.getByText('invalid something')).toBeInTheDocument(); }); - it('should display multiple base errors', () => { - const wrapper = shallow( + + it('displays multiple base errors', () => { + render( ); - expect(wrapper).toMatchSnapshot(); + expect(screen.getByText('Oops')).toBeInTheDocument(); }); - it('should dispaly form errors as warning', () => { - const wrapper = shallow( + + it('displays form errors as a warning', () => { + const { container } = render( ); - expect(wrapper).toMatchSnapshot(); + expect(container.querySelector('.alert-warning')).toBeInTheDocument(); + expect(screen.getByText('Do not feed the trolls')).toBeInTheDocument(); }); }); diff --git a/webpack/assets/javascripts/react_app/components/common/forms/__snapshots__/Form.test.js.snap b/webpack/assets/javascripts/react_app/components/common/forms/__snapshots__/Form.test.js.snap deleted file mode 100644 index da363924b1..0000000000 --- a/webpack/assets/javascripts/react_app/components/common/forms/__snapshots__/Form.test.js.snap +++ /dev/null @@ -1,125 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Form should accept base error title 1`] = ` - -`; - -exports[`Form should dispaly form errors as warning 1`] = ` - -`; - -exports[`Form should display multiple base errors 1`] = ` - -`; - -exports[`Form should display one base error 1`] = ` - -`; - -exports[`Form should render a form 1`] = ` - -`;