2022-05-06 20:55:25 +03:00
|
|
|
import { render, screen } from '@testing-library/react';
|
2023-05-27 12:57:26 +03:00
|
|
|
import { MemoryRouter } from 'react-router';
|
2022-05-03 18:36:34 +03:00
|
|
|
import { NotFound } from '../../src/common/NotFound';
|
2019-03-03 13:02:29 +03:00
|
|
|
|
|
|
|
describe('<NotFound />', () => {
|
2022-05-06 20:55:25 +03:00
|
|
|
const setUp = (props = {}) => render(<MemoryRouter><NotFound {...props} /></MemoryRouter>);
|
2019-03-03 13:02:29 +03:00
|
|
|
|
2019-03-03 13:15:34 +03:00
|
|
|
it('shows expected error title', () => {
|
2022-05-06 20:55:25 +03:00
|
|
|
setUp();
|
|
|
|
expect(screen.getByText('Oops! We could not find requested route.')).toBeInTheDocument();
|
2019-03-03 13:15:34 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('shows expected error message', () => {
|
2022-05-06 20:55:25 +03:00
|
|
|
setUp();
|
|
|
|
expect(screen.getByText(
|
2020-08-22 09:10:31 +03:00
|
|
|
'Use your browser\'s back button to navigate to the page you have previously come from, or just press this button.',
|
2022-05-06 20:55:25 +03:00
|
|
|
)).toBeInTheDocument();
|
2019-03-03 13:15:34 +03:00
|
|
|
});
|
2019-03-03 13:02:29 +03:00
|
|
|
|
2022-05-06 20:55:25 +03:00
|
|
|
it.each([
|
|
|
|
[{}, '/', 'Home'],
|
|
|
|
[{ to: '/foo/bar', children: 'Hello' }, '/foo/bar', 'Hello'],
|
|
|
|
[{ to: '/baz-bar', children: <>Foo</> }, '/baz-bar', 'Foo'],
|
|
|
|
])('shows expected link and text', (props, expectedLink, expectedText) => {
|
|
|
|
setUp(props);
|
|
|
|
const link = screen.getByRole('link');
|
|
|
|
|
|
|
|
expect(link).toHaveAttribute('href', expectedLink);
|
|
|
|
expect(link).toHaveTextContent(expectedText);
|
|
|
|
expect(link).toHaveAttribute('class', 'btn btn-outline-primary btn-lg');
|
2019-03-03 13:02:29 +03:00
|
|
|
});
|
|
|
|
});
|