Skip to content

Commit c6422c4

Browse files
committed
feat(url): improve fallback url handling
Signed-off-by: Adam Setch <[email protected]>
1 parent ba81d1e commit c6422c4

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/renderer/utils/helpers.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
mockSingleNotification,
1313
} from './api/__mocks__/response-mocks';
1414
import * as apiClient from './api/client';
15-
import * as apiRequest from './api/request';
1615
import {
1716
generateGitHubWebUrl,
1817
generateNotificationReferrerId,
@@ -73,7 +72,6 @@ describe('renderer/utils/helpers.ts', () => {
7372
const mockNotificationReferrer =
7473
'notification_referrer_id=MDE4Ok5vdGlmaWNhdGlvblRocmVhZDEzODY2MTA5NjoxMjM0NTY3ODk%3D';
7574

76-
const apiRequestAuthSpy = jest.spyOn(apiRequest, 'apiRequestAuth');
7775
const getHtmlUrlSpy = jest.spyOn(apiClient, 'getHtmlUrl');
7876
const getLatestDiscussionSpy = jest.spyOn(apiClient, 'getLatestDiscussion');
7977

@@ -465,21 +463,21 @@ describe('renderer/utils/helpers.ts', () => {
465463

466464
const subject = {
467465
title: 'generate github web url unit tests',
468-
url: 'https://api.github.com/repos/gitify-app/notifications-test/discussion/1' as Link,
466+
url: 'https://api.github.com/repos/gitify-app/notifications-test/issues/1' as Link,
469467
latest_comment_url: null as Link,
470-
type: 'Discussion' as SubjectType,
468+
type: 'Issue' as SubjectType,
471469
};
472470

473-
apiRequestAuthSpy.mockRejectedValue(new Error('Test error'));
471+
getHtmlUrlSpy.mockRejectedValue(new Error('Test error'));
474472

475473
const result = await generateGitHubWebUrl({
476474
...mockSingleNotification,
477475
subject: subject,
478476
});
479477

480-
expect(apiRequestAuthSpy).toHaveBeenCalledTimes(1);
478+
expect(getHtmlUrlSpy).toHaveBeenCalledTimes(0);
481479
expect(result).toBe(
482-
`https://github.com/gitify-app/notifications-test/discussions?${mockNotificationReferrer}`,
480+
`https://github.com/gitify-app/notifications-test/issues?${mockNotificationReferrer}`,
483481
);
484482
expect(rendererLogErrorSpy).toHaveBeenCalledTimes(1);
485483
});

0 commit comments

Comments
 (0)