-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Expand file tree
/
Copy pathnotification-details.test.tsx
More file actions
54 lines (44 loc) · 1.5 KB
/
notification-details.test.tsx
File metadata and controls
54 lines (44 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React from 'react';
import { useAppSelector } from '../../store/store';
import { renderWithProvider } from '../../../test/lib/render-helpers-navigate';
import { NOTIFICATIONS_ROUTE } from '../../helpers/constants/routes';
import NotificationDetails from './notification-details';
const configureStore = jest.requireActual('../../store/store').default;
const mockUseNavigate = jest.fn();
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useNavigate: () => mockUseNavigate,
}));
jest.mock('../../store/store', () => {
const actual = jest.requireActual('../../store/store');
return {
...actual,
useAppSelector: jest.fn(),
};
});
jest.mock('../../hooks/metamask-notifications/useNotifications', () => ({
useMarkNotificationAsRead: () => ({
markNotificationAsRead: jest.fn(),
}),
}));
jest.mock('../../hooks/useNotificationTimeouts', () => ({
useSnapNotificationTimeouts: () => ({
setNotificationTimeout: jest.fn(),
}),
}));
describe('NotificationDetails', () => {
beforeEach(() => {
mockUseNavigate.mockClear();
jest.mocked(useAppSelector).mockReturnValue(undefined);
});
it('navigates to the notifications list when the notification is not found', () => {
const store = configureStore({});
renderWithProvider(
<NotificationDetails />,
store,
`${NOTIFICATIONS_ROUTE}/missing-id`,
);
expect(mockUseNavigate).toHaveBeenCalledWith(NOTIFICATIONS_ROUTE);
expect(useAppSelector).toHaveBeenCalled();
});
});