@@ -488,8 +488,8 @@ describe('renderer/utils/helpers.ts', () => {
488488 } ) ;
489489 } ) ;
490490
491- describe ( 'defaults to repository url ' , ( ) => {
492- it ( 'defaults when no urls present in notification' , async ( ) => {
491+ describe ( 'defaults web urls ' , ( ) => {
492+ it ( 'issues - defaults when no urls present in notification' , async ( ) => {
493493 const subject = {
494494 title : 'generate github web url unit tests' ,
495495 url : null ,
@@ -504,7 +504,64 @@ describe('renderer/utils/helpers.ts', () => {
504504
505505 expect ( apiRequestAuthSpy ) . toHaveBeenCalledTimes ( 0 ) ;
506506 expect ( result ) . toBe (
507- `${ mockSingleNotification . repository . html_url } ?${ mockNotificationReferrer } ` ,
507+ `https://github.com/gitify-app/notifications-test/issues?${ mockNotificationReferrer } ` ,
508+ ) ;
509+ } ) ;
510+
511+ it ( 'discussion - defaults when no urls present in notification' , async ( ) => {
512+ const subject = {
513+ title : 'generate github web url unit tests' ,
514+ url : null ,
515+ latest_comment_url : null ,
516+ type : 'Discussion' as SubjectType ,
517+ } ;
518+
519+ const result = await generateGitHubWebUrl ( {
520+ ...mockSingleNotification ,
521+ subject : subject ,
522+ } ) ;
523+
524+ expect ( apiRequestAuthSpy ) . toHaveBeenCalledTimes ( 0 ) ;
525+ expect ( result ) . toBe (
526+ `https://github.com/gitify-app/notifications-test/discussions?${ mockNotificationReferrer } ` ,
527+ ) ;
528+ } ) ;
529+
530+ it ( 'issues - defaults when no urls present in notification' , async ( ) => {
531+ const subject = {
532+ title : 'generate github web url unit tests' ,
533+ url : null ,
534+ latest_comment_url : null ,
535+ type : 'PullRequest' as SubjectType ,
536+ } ;
537+
538+ const result = await generateGitHubWebUrl ( {
539+ ...mockSingleNotification ,
540+ subject : subject ,
541+ } ) ;
542+
543+ expect ( apiRequestAuthSpy ) . toHaveBeenCalledTimes ( 0 ) ;
544+ expect ( result ) . toBe (
545+ `https://github.com/gitify-app/notifications-test/pulls?${ mockNotificationReferrer } ` ,
546+ ) ;
547+ } ) ;
548+
549+ it ( 'other - defaults when no urls present in notification' , async ( ) => {
550+ const subject = {
551+ title : 'generate github web url unit tests' ,
552+ url : null ,
553+ latest_comment_url : null ,
554+ type : 'Commit' as SubjectType ,
555+ } ;
556+
557+ const result = await generateGitHubWebUrl ( {
558+ ...mockSingleNotification ,
559+ subject : subject ,
560+ } ) ;
561+
562+ expect ( apiRequestAuthSpy ) . toHaveBeenCalledTimes ( 0 ) ;
563+ expect ( result ) . toBe (
564+ `https://github.com/gitify-app/notifications-test?${ mockNotificationReferrer } ` ,
508565 ) ;
509566 } ) ;
510567
@@ -521,9 +578,7 @@ describe('renderer/utils/helpers.ts', () => {
521578 type : 'Issue' as SubjectType ,
522579 } ;
523580
524- const mockError = new Error ( 'Test error' ) ;
525-
526- apiRequestAuthSpy . mockRejectedValue ( mockError ) ;
581+ apiRequestAuthSpy . mockRejectedValue ( new Error ( 'Test error' ) ) ;
527582
528583 const result = await generateGitHubWebUrl ( {
529584 ...mockSingleNotification ,
@@ -537,7 +592,7 @@ describe('renderer/utils/helpers.ts', () => {
537592 mockPersonalAccessTokenAccount . token ,
538593 ) ;
539594 expect ( result ) . toBe (
540- `https://github.com/gitify-app/notifications-test?${ mockNotificationReferrer } ` ,
595+ `https://github.com/gitify-app/notifications-test/issues ?${ mockNotificationReferrer } ` ,
541596 ) ;
542597 expect ( rendererLogErrorSpy ) . toHaveBeenCalledTimes ( 2 ) ;
543598 } ) ;
0 commit comments