@@ -426,7 +426,7 @@ describe('hooks/useNotifications.ts', () => {
426
426
describe ( 'unsubscribeNotification' , ( ) => {
427
427
const id = 'notification-123' ;
428
428
429
- it ( 'should unsubscribe from a notification with success' , async ( ) => {
429
+ it ( 'should unsubscribe from a notification with success - markAsDoneOnUnsubscribe = false ' , async ( ) => {
430
430
// The unsubscribe endpoint call.
431
431
nock ( 'https://api.github.com/' )
432
432
. put ( `/notifications/threads/${ id } /subscription` )
@@ -453,6 +453,39 @@ describe('hooks/useNotifications.ts', () => {
453
453
expect ( result . current . notifications . length ) . toBe ( 0 ) ;
454
454
} ) ;
455
455
456
+ it ( 'should unsubscribe from a notification with success - markAsDoneOnUnsubscribe = true' , async ( ) => {
457
+ // The unsubscribe endpoint call.
458
+ nock ( 'https://api.github.com/' )
459
+ . put ( `/notifications/threads/${ id } /subscription` )
460
+ . reply ( 200 ) ;
461
+
462
+ // The mark done endpoint call.
463
+ nock ( 'https://api.github.com/' )
464
+ . delete ( `/notifications/threads/${ id } ` )
465
+ . reply ( 200 ) ;
466
+
467
+ const { result } = renderHook ( ( ) => useNotifications ( ) ) ;
468
+
469
+ act ( ( ) => {
470
+ result . current . unsubscribeNotification (
471
+ {
472
+ ...mockState ,
473
+ settings : {
474
+ ...mockState . settings ,
475
+ markAsDoneOnUnsubscribe : true ,
476
+ } ,
477
+ } ,
478
+ mockSingleNotification ,
479
+ ) ;
480
+ } ) ;
481
+
482
+ await waitFor ( ( ) => {
483
+ expect ( result . current . status ) . toBe ( 'success' ) ;
484
+ } ) ;
485
+
486
+ expect ( result . current . notifications . length ) . toBe ( 0 ) ;
487
+ } ) ;
488
+
456
489
it ( 'should unsubscribe from a notification with failure' , async ( ) => {
457
490
// The unsubscribe endpoint call.
458
491
nock ( 'https://api.github.com/' )
0 commit comments