2019-04-05 02:23:40 +07:00
|
|
|
import React from 'react';
|
|
|
|
import { BrowserRouter as Router } from 'react-router-dom';
|
2019-11-23 19:41:14 +07:00
|
|
|
|
|
|
|
import { render, fireEvent } from '../../utils/test-react-testing-library';
|
2019-10-08 03:19:18 +07:00
|
|
|
|
2020-03-08 22:45:07 +07:00
|
|
|
import NotFound from './NotFound';
|
2019-04-05 02:23:40 +07:00
|
|
|
|
|
|
|
describe('<NotFound /> component', () => {
|
2019-06-20 19:37:28 +07:00
|
|
|
test('should load the component in default state', () => {
|
2019-10-12 18:23:14 +07:00
|
|
|
const { container } = render(
|
2019-04-05 02:23:40 +07:00
|
|
|
<Router>
|
|
|
|
<NotFound />
|
|
|
|
</Router>
|
|
|
|
);
|
2019-10-12 18:23:14 +07:00
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
2019-04-05 02:23:40 +07:00
|
|
|
});
|
2020-03-08 22:45:07 +07:00
|
|
|
|
|
|
|
test('go to Home Page button click', async () => {
|
2019-10-26 18:13:47 +07:00
|
|
|
const spy = jest.spyOn(React, 'useCallback');
|
2020-03-08 22:45:07 +07:00
|
|
|
const { getByTestId } = render(
|
2019-10-26 18:13:47 +07:00
|
|
|
<Router>
|
|
|
|
<NotFound />
|
|
|
|
</Router>
|
|
|
|
);
|
|
|
|
|
2020-03-08 22:45:07 +07:00
|
|
|
const node = getByTestId('not-found-go-to-home-button');
|
2019-10-26 18:13:47 +07:00
|
|
|
fireEvent.click(node);
|
|
|
|
expect(spy).toHaveBeenCalled();
|
|
|
|
});
|
2019-04-05 02:23:40 +07:00
|
|
|
});
|