Skip to content

Commit 8ff3676

Browse files
committed
refactor: test suites
Signed-off-by: Adam Setch <[email protected]>
1 parent ffd8536 commit 8ff3676

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/renderer/utils/auth/utils.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import nock from 'nock';
55
import { mockGitHubCloudAccount } from '../../__mocks__/account-mocks';
66
import { mockAuth } from '../../__mocks__/state-mocks';
77
import { mockGitifyUser } from '../../__mocks__/user-mocks';
8+
import { Constants } from '../../constants';
89
import type {
910
Account,
1011
AuthCode,
@@ -153,7 +154,11 @@ describe('renderer/utils/auth/utils.ts', () => {
153154
beforeEach(() => {
154155
nock('https://api.github.com')
155156
.get('/user')
156-
.reply(200, { ...mockGitifyUser, avatar_url: mockGitifyUser.avatar });
157+
.reply(
158+
200,
159+
{ ...mockGitifyUser, avatar_url: mockGitifyUser.avatar },
160+
{ 'x-oauth-scopes': Constants.OAUTH_SCOPES.RECOMMENDED },
161+
);
157162
});
158163

159164
it('should add personal access token account', async () => {
@@ -166,6 +171,7 @@ describe('renderer/utils/auth/utils.ts', () => {
166171

167172
expect(result.accounts).toEqual([
168173
{
174+
hasRequiredScopes: true,
169175
hostname: 'github.com' as Hostname,
170176
method: 'Personal Access Token',
171177
platform: 'GitHub Cloud',
@@ -186,6 +192,7 @@ describe('renderer/utils/auth/utils.ts', () => {
186192

187193
expect(result.accounts).toEqual([
188194
{
195+
hasRequiredScopes: true,
189196
hostname: 'github.com' as Hostname,
190197
method: 'OAuth App',
191198
platform: 'GitHub Cloud',
@@ -204,7 +211,10 @@ describe('renderer/utils/auth/utils.ts', () => {
204211
.reply(
205212
200,
206213
{ ...mockGitifyUser, avatar_url: mockGitifyUser.avatar },
207-
{ 'x-github-enterprise-version': '3.0.0' },
214+
{
215+
'x-github-enterprise-version': '3.0.0',
216+
'x-oauth-scopes': Constants.OAUTH_SCOPES.RECOMMENDED,
217+
},
208218
);
209219
});
210220

@@ -218,6 +228,7 @@ describe('renderer/utils/auth/utils.ts', () => {
218228

219229
expect(result.accounts).toEqual([
220230
{
231+
hasRequiredScopes: true,
221232
hostname: 'github.gitify.io' as Hostname,
222233
method: 'Personal Access Token',
223234
platform: 'GitHub Enterprise Server',
@@ -238,6 +249,7 @@ describe('renderer/utils/auth/utils.ts', () => {
238249

239250
expect(result.accounts).toEqual([
240251
{
252+
hasRequiredScopes: true,
241253
hostname: 'github.gitify.io' as Hostname,
242254
method: 'OAuth App',
243255
platform: 'GitHub Enterprise Server',

src/renderer/utils/helpers.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ describe('renderer/utils/helpers.ts', () => {
338338
});
339339

340340
it('default to base discussions url when graphql query fails', async () => {
341+
const rendererLogErrorSpy = jest
342+
.spyOn(logger, 'rendererLogError')
343+
.mockImplementation();
344+
341345
const subject = {
342346
title: '1.16.0',
343347
url: null,
@@ -360,6 +364,7 @@ describe('renderer/utils/helpers.ts', () => {
360364
expect(result).toBe(
361365
`https://github.com/gitify-app/notifications-test/discussions?${mockNotificationReferrer}`,
362366
);
367+
expect(rendererLogErrorSpy).toHaveBeenCalledTimes(1);
363368
});
364369
});
365370

0 commit comments

Comments
 (0)