@@ -75,6 +75,18 @@ describe('Notification Redux', () => {
7575 expect ( Object . keys ( notifications ) ) . toHaveLength ( 2 ) ;
7676 } ) ;
7777
78+ it . each ( [
79+ { statusCode : 404 , status : 'failed' } ,
80+ { statusCode : 403 , status : 'denied' } ,
81+ ] ) ( '%s to load notifications list in the redux.' , async ( { statusCode, status } ) => {
82+ axiosMock . onGet ( notificationsApiUrl ) . reply ( statusCode ) ;
83+ await executeThunk ( fetchNotificationList ( { page : 1 , pageSize : 10 } ) , store . dispatch , store . getState ) ;
84+
85+ const { notifications : { notificationStatus } } = store . getState ( ) ;
86+
87+ expect ( notificationStatus ) . toEqual ( status ) ;
88+ } ) ;
89+
7890 it ( 'Successfully loaded notification counts in the redux.' , async ( ) => {
7991 const { notifications : { tabsCount } } = store . getState ( ) ;
8092
@@ -85,13 +97,37 @@ describe('Notification Redux', () => {
8597 expect ( tabsCount . authoring ) . toEqual ( 5 ) ;
8698 } ) ;
8799
100+ it . each ( [
101+ { statusCode : 404 , status : 'failed' } ,
102+ { statusCode : 403 , status : 'denied' } ,
103+ ] ) ( '%s to load notification counts in the redux.' , async ( { statusCode, status } ) => {
104+ axiosMock . onGet ( notificationCountsApiUrl ) . reply ( statusCode ) ;
105+ await executeThunk ( fetchAppsNotificationCount ( ) , store . dispatch , store . getState ) ;
106+
107+ const { notifications : { notificationStatus } } = store . getState ( ) ;
108+
109+ expect ( notificationStatus ) . toEqual ( status ) ;
110+ } ) ;
111+
88112 it ( 'Successfully marked all notifications as seen for selected app.' , async ( ) => {
89113 axiosMock . onPut ( markedAllNotificationsAsSeenApiUrl ) . reply ( 200 ) ;
90114 await executeThunk ( markNotificationsAsSeen ( 'discussions' ) , store . dispatch , store . getState ) ;
91115
92116 expect ( store . getState ( ) . notifications . notificationStatus ) . toEqual ( 'successful' ) ;
93117 } ) ;
94118
119+ it . each ( [
120+ { statusCode : 404 , status : 'failed' } ,
121+ { statusCode : 403 , status : 'denied' } ,
122+ ] ) ( '%s to mark all notifications as seen for selected app.' , async ( { statusCode, status } ) => {
123+ axiosMock . onPut ( markedAllNotificationsAsSeenApiUrl ) . reply ( statusCode ) ;
124+ await executeThunk ( markNotificationsAsSeen ( 'discussions' ) , store . dispatch , store . getState ) ;
125+
126+ const { notifications : { notificationStatus } } = store . getState ( ) ;
127+
128+ expect ( notificationStatus ) . toEqual ( status ) ;
129+ } ) ;
130+
95131 it ( 'Successfully marked all notifications as read for selected app in the redux.' , async ( ) => {
96132 axiosMock . onPut ( markedAllNotificationsAsReadApiUrl ) . reply ( 200 ) ;
97133 await executeThunk ( markAllNotificationsAsRead ( 'discussions' ) , store . dispatch , store . getState ) ;
@@ -103,6 +139,18 @@ describe('Notification Redux', () => {
103139 expect ( firstNotification . lastRead ) . not . toBeNull ( ) ;
104140 } ) ;
105141
142+ it . each ( [
143+ { statusCode : 404 , status : 'failed' } ,
144+ { statusCode : 403 , status : 'denied' } ,
145+ ] ) ( '%s to mark all notifications as read for selected app in the redux.' , async ( { statusCode, status } ) => {
146+ axiosMock . onPut ( markedAllNotificationsAsReadApiUrl ) . reply ( statusCode ) ;
147+ await executeThunk ( markAllNotificationsAsRead ( 'discussions' ) , store . dispatch , store . getState ) ;
148+
149+ const { notifications : { notificationStatus } } = store . getState ( ) ;
150+
151+ expect ( notificationStatus ) . toEqual ( status ) ;
152+ } ) ;
153+
106154 it ( 'Successfully marked notification as read in the redux.' , async ( ) => {
107155 axiosMock . onPut ( markedAllNotificationsAsReadApiUrl ) . reply ( 200 ) ;
108156 await executeThunk ( markNotificationsAsRead ( 1 ) , store . dispatch , store . getState ) ;
@@ -113,4 +161,16 @@ describe('Notification Redux', () => {
113161 expect ( notificationStatus ) . toEqual ( 'successful' ) ;
114162 expect ( firstNotification . lastRead ) . not . toBeNull ( ) ;
115163 } ) ;
164+
165+ it . each ( [
166+ { statusCode : 404 , status : 'failed' } ,
167+ { statusCode : 403 , status : 'denied' } ,
168+ ] ) ( '%s to marked notification as read in the redux.' , async ( { statusCode, status } ) => {
169+ axiosMock . onPut ( markedAllNotificationsAsReadApiUrl ) . reply ( statusCode ) ;
170+ await executeThunk ( markNotificationsAsRead ( 1 ) , store . dispatch , store . getState ) ;
171+
172+ const { notifications : { notificationStatus } } = store . getState ( ) ;
173+
174+ expect ( notificationStatus ) . toEqual ( status ) ;
175+ } ) ;
116176} ) ;
0 commit comments