mirror of
https://github.com/SomboChea/ui
synced 2026-01-17 00:25:50 +07:00
* refactor: adds missing test spec for button click in not found * refactor: improves test description
30 lines
770 B
TypeScript
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();
|
|
});
|
|
});
|