We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d894ab8 commit c286bd0Copy full SHA for c286bd0
1 file changed
src/course-rerun/CourseRerun.test.jsx
@@ -17,6 +17,13 @@ jest.mock('react-redux', () => ({
17
useSelector: jest.fn(),
18
}));
19
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
27
describe('<CourseRerun />', () => {
28
beforeEach(() => {
29
const { axiosMock } = initializeMocks();
@@ -36,7 +43,7 @@ describe('<CourseRerun />', () => {
36
43
37
44
fireEvent.click(cancelButton);
38
45
await waitFor(() => {
39
- expect(window.location.pathname).toBe('/home');
46
+ expect(mockNavigate).toHaveBeenCalledWith('/home');
40
47
});
41
48
42
49
0 commit comments