1
0
mirror of https://github.com/SomboChea/ui synced 2026-01-17 00:25:50 +07:00
Files
verdaccio-ui/src/components/NotFound/Notfound.test.tsx
Ayush Sharma 531295a6d0 refactor: adds missing test spec for button click in not found (#222)
* refactor: adds missing test spec for button click in not found

* refactor: improves test description
2019-10-26 13:13:47 +02:00

30 lines
770 B
TypeScript

import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { render, fireEvent } from '@testing-library/react';
import NotFound, { GO_TO_HOME_PAGE } from './NotFound';
describe('<NotFound /> component', () => {
test('should load the component in default state', () => {
const { container } = render(
<Router>
<NotFound />
</Router>
);
expect(container.firstChild).toMatchSnapshot();
});
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();
});
});