@@ -5,8 +5,7 @@ import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
5
5
import { initializeMockApp } from '@edx/frontend-platform/testing' ;
6
6
7
7
import { initializeStore } from '../../store' ;
8
- import executeThunk from '../../test-utils' ;
9
- import { getNotificationsListApiUrl , getNotificationsCountApiUrl } from './api' ;
8
+ import mockNotificationsResponse from '../test-utils' ;
10
9
import {
11
10
selectNotifications ,
12
11
selectNotificationsByIds ,
@@ -18,13 +17,9 @@ import {
18
17
selectSelectedAppNotificationIds ,
19
18
selectShowNotificationTray ,
20
19
} from './selectors' ;
21
- import { fetchAppsNotificationCount , fetchNotificationList } from './thunks' ;
22
20
23
21
import './__factories__' ;
24
22
25
- const notificationCountsApiUrl = getNotificationsCountApiUrl ( ) ;
26
- const notificationsApiUrl = getNotificationsListApiUrl ( ) ;
27
-
28
23
let axiosMock ;
29
24
let store ;
30
25
@@ -42,10 +37,7 @@ describe('Notification Selectors', () => {
42
37
Factory . resetAll ( ) ;
43
38
store = initializeStore ( ) ;
44
39
45
- axiosMock . onGet ( notificationCountsApiUrl ) . reply ( 200 , ( Factory . build ( 'notificationsCount' ) ) ) ;
46
- axiosMock . onGet ( notificationsApiUrl ) . reply ( 200 , ( Factory . build ( 'notificationsList' ) ) ) ;
47
- await executeThunk ( fetchAppsNotificationCount ( ) , store . dispatch , store . getState ) ;
48
- await executeThunk ( fetchNotificationList ( { appName : 'discussion' , page : 1 } ) , store . dispatch , store . getState ) ;
40
+ ( { store, axiosMock } = await mockNotificationsResponse ( ) ) ;
49
41
} ) ;
50
42
51
43
afterEach ( ( ) => {
@@ -81,7 +73,7 @@ describe('Notification Selectors', () => {
81
73
const state = store . getState ( ) ;
82
74
const notificationIds = selectSelectedAppNotificationIds ( 'discussion' ) ( state ) ;
83
75
84
- expect ( notificationIds ) . toHaveLength ( 2 ) ;
76
+ expect ( notificationIds ) . toHaveLength ( 10 ) ;
85
77
} ) ;
86
78
87
79
it ( 'Should return show notification tray status.' , async ( ) => {
@@ -95,14 +87,14 @@ describe('Notification Selectors', () => {
95
87
const state = store . getState ( ) ;
96
88
const notifications = selectNotifications ( ) ( state ) ;
97
89
98
- expect ( Object . keys ( notifications ) ) . toHaveLength ( 2 ) ;
90
+ expect ( Object . keys ( notifications ) ) . toHaveLength ( 10 ) ;
99
91
} ) ;
100
92
101
93
it ( 'Should return notifications from Ids.' , async ( ) => {
102
94
const state = store . getState ( ) ;
103
95
const notifications = selectNotificationsByIds ( 'discussion' ) ( state ) ;
104
96
105
- expect ( notifications ) . toHaveLength ( 2 ) ;
97
+ expect ( notifications ) . toHaveLength ( 10 ) ;
106
98
} ) ;
107
99
108
100
it ( 'Should return selected app name.' , async ( ) => {
@@ -117,7 +109,7 @@ describe('Notification Selectors', () => {
117
109
const paginationData = selectPaginationData ( ) ( state ) ;
118
110
119
111
expect ( paginationData . currentPage ) . toEqual ( 1 ) ;
120
- expect ( paginationData . totalPages ) . toEqual ( 1 ) ;
121
- expect ( paginationData . nextPage ) . toEqual ( null ) ;
112
+ expect ( paginationData . numPages ) . toEqual ( 2 ) ;
113
+ expect ( paginationData . hasMorePages ) . toEqual ( true ) ;
122
114
} ) ;
123
115
} ) ;
0 commit comments