Skip to content

Commit c286bd0

Browse files
test: fix broken test
1 parent d894ab8 commit c286bd0

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/course-rerun/CourseRerun.test.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ jest.mock('react-redux', () => ({
1717
useSelector: jest.fn(),
1818
}));
1919

20+
const mockNavigate = jest.fn();
21+
22+
jest.mock('react-router-dom', () => ({
23+
...jest.requireActual('react-router-dom'), // use actual for all non-hook parts
24+
useNavigate: () => mockNavigate,
25+
}));
26+
2027
describe('<CourseRerun />', () => {
2128
beforeEach(() => {
2229
const { axiosMock } = initializeMocks();
@@ -36,7 +43,7 @@ describe('<CourseRerun />', () => {
3643

3744
fireEvent.click(cancelButton);
3845
await waitFor(() => {
39-
expect(window.location.pathname).toBe('/home');
46+
expect(mockNavigate).toHaveBeenCalledWith('/home');
4047
});
4148
});
4249

0 commit comments

Comments
 (0)