@@ -355,6 +355,92 @@ describe('hooks/useNotifications.ts', () => {
355355 } ) ;
356356 } ) ;
357357
358+ describe ( 'markNotificationDone' , ( ) => {
359+ const id = 'notification-123' ;
360+
361+ describe ( 'github.com' , ( ) => {
362+ const accounts = { ...mockAccounts , enterpriseAccounts : [ ] } ;
363+ const hostname = 'github.com' ;
364+
365+ it ( 'should mark a notification as done with success - github.com' , async ( ) => {
366+ nock ( 'https://api.github.com/' )
367+ . delete ( `/notifications/threads/${ id } ` )
368+ . reply ( 200 ) ;
369+
370+ const { result } = renderHook ( ( ) => useNotifications ( false ) ) ;
371+
372+ act ( ( ) => {
373+ result . current . markNotificationDone ( accounts , id , hostname ) ;
374+ } ) ;
375+
376+ await waitFor ( ( ) => {
377+ expect ( result . current . isFetching ) . toBe ( false ) ;
378+ } ) ;
379+
380+ expect ( result . current . notifications . length ) . toBe ( 0 ) ;
381+ } ) ;
382+
383+ it ( 'should mark a notification as done with failure - github.com' , async ( ) => {
384+ nock ( 'https://api.github.com/' )
385+ . delete ( `/notifications/threads/${ id } ` )
386+ . reply ( 400 ) ;
387+
388+ const { result } = renderHook ( ( ) => useNotifications ( false ) ) ;
389+
390+ act ( ( ) => {
391+ result . current . markNotificationDone ( accounts , id , hostname ) ;
392+ } ) ;
393+
394+ await waitFor ( ( ) => {
395+ expect ( result . current . isFetching ) . toBe ( false ) ;
396+ } ) ;
397+
398+ expect ( result . current . notifications . length ) . toBe ( 0 ) ;
399+ } ) ;
400+ } ) ;
401+
402+ describe ( 'enterprise' , ( ) => {
403+ const accounts = { ...mockAccounts , token : null } ;
404+ const hostname = 'github.gitify.io' ;
405+
406+ it ( 'should mark a notification as done with success - enterprise' , async ( ) => {
407+ nock ( 'https://github.gitify.io/' )
408+ . delete ( `/notifications/threads/${ id } ` )
409+ . reply ( 200 ) ;
410+
411+ const { result } = renderHook ( ( ) => useNotifications ( false ) ) ;
412+
413+ act ( ( ) => {
414+ result . current . markNotificationDone ( accounts , id , hostname ) ;
415+ } ) ;
416+
417+ await waitFor ( ( ) => {
418+ expect ( result . current . isFetching ) . toBe ( false ) ;
419+ } ) ;
420+
421+ expect ( result . current . notifications . length ) . toBe ( 0 ) ;
422+ } ) ;
423+
424+ it ( 'should mark a notification as done with failure - enterprise' , async ( ) => {
425+ nock ( 'https://github.gitify.io/' )
426+ . delete ( `/notifications/threads/${ id } ` )
427+ . reply ( 400 ) ;
428+
429+ const { result } = renderHook ( ( ) => useNotifications ( false ) ) ;
430+
431+ act ( ( ) => {
432+ result . current . markNotificationDone ( accounts , id , hostname ) ;
433+ } ) ;
434+
435+ await waitFor ( ( ) => {
436+ expect ( result . current . isFetching ) . toBe ( false ) ;
437+ } ) ;
438+
439+ expect ( result . current . notifications . length ) . toBe ( 0 ) ;
440+ } ) ;
441+ } ) ;
442+ } ) ;
443+
358444 describe ( 'unsubscribeNotification' , ( ) => {
359445 const id = 'notification-123' ;
360446
0 commit comments