@@ -269,6 +269,42 @@ describe('hooks/useNotifications.ts', () => {
269
269
} ) ;
270
270
} ) ;
271
271
272
+ describe ( 'removeNotificationFromState' , ( ) => {
273
+ it ( 'should remove a notification from state' , async ( ) => {
274
+ const notifications = [
275
+ { id : 1 , title : 'This is a notification.' } ,
276
+ { id : 2 , title : 'This is another one.' } ,
277
+ ] ;
278
+
279
+ nock ( 'https://api.github.com' )
280
+ . get ( '/notifications?participating=false' )
281
+ . reply ( 200 , notifications ) ;
282
+
283
+ nock ( 'https://github.gitify.io/api/v3' )
284
+ . get ( '/notifications?participating=false' )
285
+ . reply ( 200 , notifications ) ;
286
+
287
+ const { result } = renderHook ( ( ) => useNotifications ( false ) ) ;
288
+
289
+ act ( ( ) => {
290
+ result . current . fetchNotifications ( mockAccounts , mockSettings ) ;
291
+ } ) ;
292
+
293
+ await waitFor ( ( ) => {
294
+ expect ( result . current . isFetching ) . toBe ( false ) ;
295
+ } ) ;
296
+
297
+ act ( ( ) => {
298
+ result . current . removeNotificationFromState (
299
+ result . current . notifications [ 0 ] . notifications [ 0 ] . id ,
300
+ result . current . notifications [ 0 ] . hostname ,
301
+ ) ;
302
+ } ) ;
303
+
304
+ expect ( result . current . notifications [ 0 ] . notifications . length ) . toBe ( 1 ) ;
305
+ } ) ;
306
+ } ) ;
307
+
272
308
describe ( 'markNotification' , ( ) => {
273
309
const id = 'notification-123' ;
274
310
0 commit comments