Skip to content

Commit ce0ed85

Browse files
committed
remove axios test helper
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent 94292a1 commit ce0ed85

9 files changed

Lines changed: 3 additions & 55 deletions

File tree

src/renderer/__helpers__/test-utils.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ interface AppContextProviderProps {
2121
* Wrapper component that provides ThemeProvider, BaseStyles, and AppContext
2222
* with sensible defaults for testing.
2323
*/
24-
export function AppContextProvider({
25-
children,
26-
value = {},
27-
}: AppContextProviderProps) {
24+
function AppContextProvider({ children, value = {} }: AppContextProviderProps) {
2825
const defaultValue: AppContextState = useMemo(() => {
2926
return {
3027
auth: mockAuth,
@@ -96,13 +93,3 @@ export function renderWithAppContext(
9693
export function ensureStableEmojis() {
9794
globalThis.Math.random = jest.fn(() => 0.1);
9895
}
99-
100-
/**
101-
* Configure HTTP mocking for tests that use nock.
102-
*
103-
* Octokit uses @octokit/request which is compatible with nock's HTTP interception.
104-
* No special configuration is needed.
105-
*/
106-
export function configureAxiosHttpAdapterForNock() {
107-
// No-op: Octokit's @octokit/request works with nock by default
108-
}

src/renderer/hooks/useNotifications.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { act, renderHook, waitFor } from '@testing-library/react';
22

33
import nock from 'nock';
44

5-
import {
6-
configureAxiosHttpAdapterForNock,
7-
type DeepPartial,
8-
} from '../__helpers__/test-utils';
5+
import type { DeepPartial } from '../__helpers__/test-utils';
96
import {
107
mockGitHubCloudAccount,
118
mockGitHubEnterpriseServerAccount,
@@ -35,10 +32,9 @@ describe('renderer/hooks/useNotifications.ts', () => {
3532
.mockImplementation();
3633

3734
beforeEach(() => {
38-
configureAxiosHttpAdapterForNock();
39-
4035
jest.clearAllMocks();
4136
// Reset mock notification state between tests since it's mutated
37+
// FIXME - isolate test data between tests
4238
mockGitifyNotification.unread = true;
4339
});
4440

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { configureAxiosHttpAdapterForNock } from '../../__helpers__/test-utils';
21
import { mockGitHubCloudAccount } from '../../__mocks__/account-mocks';
32
import { mockAuth } from '../../__mocks__/state-mocks';
43

@@ -32,10 +31,6 @@ const exchangeWebFlowCodeMock = exchangeWebFlowCode as jest.MockedFunction<
3231
>;
3332

3433
describe('renderer/utils/auth/utils.ts', () => {
35-
beforeEach(() => {
36-
configureAxiosHttpAdapterForNock();
37-
});
38-
3934
describe('authGitHub', () => {
4035
jest.spyOn(logger, 'rendererLogInfo').mockImplementation();
4136
const openExternalLinkSpy = jest

src/renderer/utils/notifications/handlers/commit.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import nock from 'nock';
22

3-
import { configureAxiosHttpAdapterForNock } from '../../../__helpers__/test-utils';
43
import { mockPartialGitifyNotification } from '../../../__mocks__/notifications-mocks';
54
import { mockSettings } from '../../../__mocks__/state-mocks';
65
import { mockRawUser } from '../../api/__mocks__/response-mocks';
@@ -14,10 +13,6 @@ import type {
1413
import { commitHandler } from './commit';
1514

1615
describe('renderer/utils/notifications/handlers/commit.ts', () => {
17-
beforeEach(() => {
18-
configureAxiosHttpAdapterForNock();
19-
});
20-
2116
describe('enrich', () => {
2217
const mockAuthor = mockRawUser('some-author');
2318
const mockCommenter = mockRawUser('some-commenter');

src/renderer/utils/notifications/handlers/discussion.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import nock from 'nock';
22

3-
import { configureAxiosHttpAdapterForNock } from '../../../__helpers__/test-utils';
43
import { mockPartialGitifyNotification } from '../../../__mocks__/notifications-mocks';
54
import { mockSettings } from '../../../__mocks__/state-mocks';
65
import {
@@ -22,10 +21,6 @@ import type { FetchDiscussionByNumberQuery } from '../../api/graphql/generated/g
2221
import { discussionHandler } from './discussion';
2322

2423
describe('renderer/utils/notifications/handlers/discussion.ts', () => {
25-
beforeEach(() => {
26-
configureAxiosHttpAdapterForNock();
27-
});
28-
2924
describe('supportsMergedQueryEnrichment', () => {
3025
it('should support merge query', () => {
3126
expect(discussionHandler.supportsMergedQueryEnrichment).toBeTruthy();

src/renderer/utils/notifications/handlers/issue.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import nock from 'nock';
22

3-
import { configureAxiosHttpAdapterForNock } from '../../../__helpers__/test-utils';
43
import { mockPartialGitifyNotification } from '../../../__mocks__/notifications-mocks';
54
import { mockSettings } from '../../../__mocks__/state-mocks';
65
import {
@@ -21,10 +20,6 @@ import type { FetchIssueByNumberQuery } from '../../api/graphql/generated/graphq
2120
import { issueHandler } from './issue';
2221

2322
describe('renderer/utils/notifications/handlers/issue.ts', () => {
24-
beforeEach(() => {
25-
configureAxiosHttpAdapterForNock();
26-
});
27-
2823
describe('supportsMergedQueryEnrichment', () => {
2924
it('should support merge query', () => {
3025
expect(issueHandler.supportsMergedQueryEnrichment).toBeTruthy();

src/renderer/utils/notifications/handlers/pullRequest.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import nock from 'nock';
22

3-
import { configureAxiosHttpAdapterForNock } from '../../../__helpers__/test-utils';
43
import { mockPartialGitifyNotification } from '../../../__mocks__/notifications-mocks';
54
import { mockSettings } from '../../../__mocks__/state-mocks';
65
import {
@@ -24,10 +23,6 @@ import type {
2423
import { getLatestReviewForReviewers, pullRequestHandler } from './pullRequest';
2524

2625
describe('renderer/utils/notifications/handlers/pullRequest.ts', () => {
27-
beforeEach(() => {
28-
configureAxiosHttpAdapterForNock();
29-
});
30-
3126
describe('mergeQueryConfig', () => {
3227
describe('supportsMergedQueryEnrichment', () => {
3328
it('should support merge query', () => {

src/renderer/utils/notifications/handlers/release.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import nock from 'nock';
22

3-
import { configureAxiosHttpAdapterForNock } from '../../../__helpers__/test-utils';
43
import { mockPartialGitifyNotification } from '../../../__mocks__/notifications-mocks';
54
import { mockSettings } from '../../../__mocks__/state-mocks';
65
import { mockRawUser } from '../../api/__mocks__/response-mocks';
@@ -19,10 +18,6 @@ describe('renderer/utils/notifications/handlers/release.ts', () => {
1918
'https://api.github.com/repos/gitify-app/notifications-test/releases/1' as Link,
2019
});
2120

22-
beforeEach(() => {
23-
configureAxiosHttpAdapterForNock();
24-
});
25-
2621
describe('enrich', () => {
2722
const mockAuthor = mockRawUser('some-author');
2823

src/renderer/utils/notifications/notifications.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import nock from 'nock';
22

3-
import { configureAxiosHttpAdapterForNock } from '../../__helpers__/test-utils';
43
import {
54
mockGitHubCloudAccount,
65
mockGitHubEnterpriseServerAccount,
@@ -34,10 +33,6 @@ import {
3433
} from './notifications';
3534

3635
describe('renderer/utils/notifications/notifications.ts', () => {
37-
beforeEach(() => {
38-
configureAxiosHttpAdapterForNock();
39-
});
40-
4136
afterEach(() => {
4237
jest.clearAllMocks();
4338
});

0 commit comments

Comments
 (0)