Skip to content

Commit 741461c

Browse files
committed
feat(test): migrate from jest to vitest
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent 75e9724 commit 741461c

5 files changed

Lines changed: 18 additions & 13 deletions

File tree

src/main/events.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import type { Menubar } from 'menubar';
1414

1515
import { handleMainEvent, onMainEvent, sendRendererEvent } from './events';
1616

17-
type MockMenubar = { window: { webContents: { send: vi.Mock } } };
17+
type MockMenubar = {
18+
window: { webContents: { send: ReturnType<typeof vi.fn> } };
19+
};
1820

1921
describe('main/events', () => {
2022
beforeEach(() => {

src/preload/utils.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import { ipcRenderer } from 'electron';
3030

3131
describe('preload/utils', () => {
3232
afterEach(() => {
33-
(ipcRenderer.send as vi.Mock).mockClear();
34-
(ipcRenderer.invoke as vi.Mock).mockClear();
35-
(ipcRenderer.on as vi.Mock).mockClear();
33+
vi.mocked(ipcRenderer.send).mockClear();
34+
vi.mocked(ipcRenderer.invoke).mockClear();
35+
vi.mocked(ipcRenderer.on).mockClear();
3636
});
3737

3838
it('sendMainEvent forwards to ipcRenderer.send', () => {

src/renderer/context/App.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { act, waitFor } from '@testing-library/react';
1+
import { act } from '@testing-library/react';
22

33
import { renderWithAppContext } from '../__helpers__/test-utils';
44
import { mockGitHubCloudAccount } from '../__mocks__/account-mocks';

src/renderer/utils/api/request.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ vi.mock('@octokit/plugin-rest-endpoint-methods', () => ({
3232

3333
describe('renderer/utils/api/request.ts', () => {
3434
let mockOctokitInstance: {
35-
request: vi.Mock;
36-
graphql: vi.Mock;
37-
paginate: { iterator: vi.Mock };
35+
request: ReturnType<typeof vi.fn>;
36+
graphql: ReturnType<typeof vi.fn>;
37+
paginate: { iterator: ReturnType<typeof vi.fn> };
3838
};
3939

4040
const createOctokitClientSpy = vi.spyOn(octokitModule, 'createOctokitClient');

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
exchangeWebFlowCode,
1818
} from '@octokit/oauth-methods';
1919

20+
import type { MockedFunction } from 'vitest';
21+
2022
import { mockGitHubCloudAccount } from '../../__mocks__/account-mocks';
2123
import { mockAuth } from '../../__mocks__/state-mocks';
2224
import { mockRawUser } from '../api/__mocks__/response-mocks';
@@ -46,15 +48,16 @@ import {
4648
getNewTokenURL,
4749
} from './utils';
4850

49-
const createDeviceCodeMock = createDeviceCode as vi.MockedFunction<
51+
const createDeviceCodeMock = createDeviceCode as unknown as MockedFunction<
5052
typeof createDeviceCode
5153
>;
52-
const exchangeDeviceCodeMock = exchangeDeviceCode as vi.MockedFunction<
54+
55+
const exchangeDeviceCodeMock = exchangeDeviceCode as unknown as MockedFunction<
5356
typeof exchangeDeviceCode
5457
>;
55-
const exchangeWebFlowCodeMock = exchangeWebFlowCode as vi.MockedFunction<
56-
typeof exchangeWebFlowCode
57-
>;
58+
59+
const exchangeWebFlowCodeMock =
60+
exchangeWebFlowCode as unknown as MockedFunction<typeof exchangeWebFlowCode>;
5861

5962
describe('renderer/utils/auth/utils.ts', () => {
6063
vi.spyOn(logger, 'rendererLogInfo').mockImplementation(vi.fn());

0 commit comments

Comments
 (0)