Created
April 6, 2021 18:21
-
-
Save Frodigo/d0449891b9aa7d1bbd9955b6c38e8058 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render, getByText } from '@testing-library/react'; | |
import ErrorMessage from '../ErrorMessage'; | |
test('ErrorMessage renders correctly', () => { | |
const { container } = render( | |
<ErrorMessage error={{message: 'Something went wrong.'}}/> | |
); | |
expect(getByText(container, 'Something went wrong.')).toBeDefined(); | |
expect(container).toMatchSnapshot(); | |
}); | |
test('ErrorMessage does not render if error message is empty', () => { | |
const { container } = render( | |
<ErrorMessage error={{message: ''}}/> | |
); | |
expect(container.firstChild).toBeNull(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment