@@ -40,7 +40,10 @@ describe('Notification Redux', () => {
4040 store = initializeStore ( ) ;
4141
4242 axiosMock . onGet ( notificationCountsApiUrl ) . reply ( 200 , ( Factory . build ( 'notificationsCount' ) ) ) ;
43- axiosMock . onGet ( notificationsApiUrl ) . reply ( 200 , ( Factory . buildList ( 'notification' , 2 , null ) ) ) ;
43+ axiosMock . onGet ( notificationsApiUrl ) . reply (
44+ 200 ,
45+ ( Factory . buildList ( 'notification' , 2 , null , { createdDate : new Date ( ) . toISOString ( ) } ) ) ,
46+ ) ;
4447 await executeThunk ( fetchAppsNotificationCount ( ) , store . dispatch , store . getState ) ;
4548 await executeThunk ( fetchNotificationList ( { page : 1 , pageSize : 10 } ) , store . dispatch , store . getState ) ;
4649 } ) ;
@@ -68,9 +71,9 @@ describe('Notification Redux', () => {
6871 } ) ;
6972
7073 it ( 'successfully loaded notifications list in the redux.' , async ( ) => {
71- const state = store . getState ( ) ;
74+ const { notifications : { notifications } } = store . getState ( ) ;
7275
73- expect ( Object . keys ( state . notifications . notifications ) ) . toHaveLength ( 2 ) ;
76+ expect ( Object . keys ( notifications ) ) . toHaveLength ( 2 ) ;
7477 } ) ;
7578
7679 it ( 'successfully loaded notification counts in the redux.' , async ( ) => {
@@ -84,9 +87,9 @@ describe('Notification Redux', () => {
8487 } ) ;
8588
8689 it ( 'successfully loaded showNotificationTray status in the redux based on api.' , async ( ) => {
87- const state = store . getState ( ) ;
90+ const { notifications : { showNotificationTray } } = store . getState ( ) ;
8891
89- expect ( state . notifications . showNotificationTray ) . toEqual ( true ) ;
92+ expect ( showNotificationTray ) . toEqual ( true ) ;
9093 } ) ;
9194
9295 it ( 'successfully store the count, numPages, currentPage, and nextPage data in redux.' , async ( ) => {
@@ -98,15 +101,15 @@ describe('Notification Redux', () => {
98101 } ) ;
99102
100103 it ( 'successfully updated the selected app name in redux.' , async ( ) => {
101- const state = store . getState ( ) ;
104+ const { notifications : { appName } } = store . getState ( ) ;
102105
103- expect ( state . notifications . appName ) . toEqual ( 'discussions' ) ;
106+ expect ( appName ) . toEqual ( 'discussions' ) ;
104107 } ) ;
105108
106109 it ( 'successfully store notification ids in the selected app in apps.' , async ( ) => {
107- const state = store . getState ( ) ;
110+ const { notifications : { apps } } = store . getState ( ) ;
108111
109- expect ( state . notifications . apps . discussions ) . toHaveLength ( 2 ) ;
112+ expect ( apps . discussions ) . toHaveLength ( 2 ) ;
110113 } ) ;
111114
112115 it ( 'successfully marked all notifications as seen for selected app.' , async ( ) => {
@@ -120,21 +123,21 @@ describe('Notification Redux', () => {
120123 axiosMock . onPut ( markedAllNotificationsAsReadApiUrl ) . reply ( 200 ) ;
121124 await executeThunk ( markAllNotificationsAsRead ( 'discussions' ) , store . dispatch , store . getState ) ;
122125
123- const { notifications } = store . getState ( ) ;
124- const firstNotification = Object . values ( notifications . notifications ) [ 0 ] ;
126+ const { notifications : { notificationStatus , notifications } } = store . getState ( ) ;
127+ const firstNotification = Object . values ( notifications ) [ 0 ] ;
125128
126- expect ( notifications . notificationStatus ) . toEqual ( 'successful' ) ;
129+ expect ( notificationStatus ) . toEqual ( 'successful' ) ;
127130 expect ( firstNotification . lastRead ) . not . toBeNull ( ) ;
128131 } ) ;
129132
130133 it ( 'successfully marked notification as read in the redux.' , async ( ) => {
131134 axiosMock . onPut ( markedNotificationAsReadApiUrl ) . reply ( 200 ) ;
132135 await executeThunk ( markNotificationsAsRead ( 'discussions' , 1 ) , store . dispatch , store . getState ) ;
133136
134- const { notifications } = store . getState ( ) ;
135- const firstNotification = Object . values ( notifications . notifications ) [ 0 ] ;
137+ const { notifications : { notificationStatus , notifications } } = store . getState ( ) ;
138+ const firstNotification = Object . values ( notifications ) [ 0 ] ;
136139
137- expect ( notifications . notificationStatus ) . toEqual ( 'successful' ) ;
140+ expect ( notificationStatus ) . toEqual ( 'successful' ) ;
138141 expect ( firstNotification . lastRead ) . not . toBeNull ( ) ;
139142 } ) ;
140143} ) ;
0 commit comments