Skip to content

Commit 7f213dc

Browse files
committed
refactor: notification handlers
Signed-off-by: Adam Setch <[email protected]>
1 parent cdd0a09 commit 7f213dc

24 files changed

+2249
-2121
lines changed

src/renderer/__helpers__/jest.setup.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import '@testing-library/jest-dom';
2-
32
import { TextDecoder, TextEncoder } from 'node:util';
43

4+
import axios from 'axios';
5+
56
/**
67
* Prevent the following errors with jest:
78
* - ReferenceError: TextEncoder is not defined
@@ -36,3 +37,7 @@ global.ResizeObserver = class {
3637
unobserve() {}
3738
disconnect() {}
3839
};
40+
41+
// axios will default to using the XHR adapter which can't be intercepted
42+
// by nock. So, configure axios to use the node adapter.
43+
axios.defaults.adapter = 'http';

src/renderer/__mocks__/notifications-mocks.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { AccountNotifications } from '../types';
2+
import type { StateType, Subject, SubjectType } from '../typesGitHub';
23
import {
34
mockEnterpriseNotifications,
45
mockGitHubNotifications,
@@ -28,3 +29,17 @@ export const mockSingleAccountNotifications: AccountNotifications[] = [
2829
error: null,
2930
},
3031
];
32+
33+
export function createSubjectMock(mocks: {
34+
title?: string;
35+
type?: SubjectType;
36+
state?: StateType;
37+
}): Subject {
38+
return {
39+
title: mocks.title ?? 'Mock Subject',
40+
type: mocks.type ?? ('Unknown' as SubjectType),
41+
state: mocks.state ?? ('Unknown' as StateType),
42+
url: null,
43+
latest_comment_url: null,
44+
};
45+
}

src/renderer/components/settings/__snapshots__/SettingsFooter.test.tsx.snap

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)