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
|
|
|
|
2019-10-26 18:13:47 +07:00
|
|
|
import NotFound, { GO_TO_HOME_PAGE } 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
|
|
|
});
|
2019-10-26 18:13:47 +07:00
|
|
|
test('go to Home Page button click', () => {
|
|
|
|
const spy = jest.spyOn(React, 'useCallback');
|
|
|
|
const { getByText } = render(
|
|
|
|
<Router>
|
|
|
|
<NotFound />
|
|
|
|
</Router>
|
|
|
|
);
|
|
|
|
|
|
|
|
const node = getByText(GO_TO_HOME_PAGE);
|
|
|
|
fireEvent.click(node);
|
|
|
|
|
|
|
|
expect(spy).toHaveBeenCalled();
|
|
|
|
});
|
2019-04-05 02:23:40 +07:00
|
|
|
});
|