mirror of
https://github.com/SomboChea/ui
synced 2026-01-18 09:06:14 +07:00
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
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import { render } from '@testing-library/react';
|
||||
import { render, fireEvent } from '@testing-library/react';
|
||||
|
||||
import NotFound from './NotFound';
|
||||
import NotFound, { GO_TO_HOME_PAGE } from './NotFound';
|
||||
|
||||
describe('<NotFound /> component', () => {
|
||||
test('should load the component in default state', () => {
|
||||
@@ -13,5 +13,17 @@ describe('<NotFound /> component', () => {
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
test.todo('Test Button Click');
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user