Skip to content

Commit 89aebba

Browse files
authored
Refactored src/components/AddOn/* from jest to Vitest (#2917)
1 parent 74305b0 commit 89aebba

File tree

4 files changed

+30
-287
lines changed

4 files changed

+30
-287
lines changed

src/components/AddOn/core/AddOnEntry/AddOnEntry.test.tsx

Lines changed: 0 additions & 236 deletions
This file was deleted.

src/components/AddOn/core/AddOnStore/AddOnStore.test.tsx renamed to src/components/AddOn/core/AddOnStore/AddOnStore.spec.tsx

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { act } from 'react';
2-
import 'jest-location-mock';
32
import { fireEvent, render, screen } from '@testing-library/react';
43
import {
54
ApolloClient,
@@ -20,17 +19,18 @@ import { ORGANIZATIONS_LIST, PLUGIN_GET } from 'GraphQl/Queries/Queries';
2019
import userEvent from '@testing-library/user-event';
2120
import useLocalStorage from 'utils/useLocalstorage';
2221
import { MockedProvider } from '@apollo/react-testing';
22+
import { vi, describe, test, expect } from 'vitest';
2323

2424
const { getItem } = useLocalStorage();
2525
interface InterfacePlugin {
2626
enabled: boolean;
2727
pluginName: string;
2828
component: string;
2929
}
30-
jest.mock('components/AddOn/support/services/Plugin.helper', () => ({
30+
vi.mock('components/AddOn/support/services/Plugin.helper', () => ({
3131
__esModule: true,
32-
default: jest.fn().mockImplementation(() => ({
33-
fetchStore: jest.fn().mockResolvedValue([
32+
default: vi.fn().mockImplementation(() => ({
33+
fetchStore: vi.fn().mockResolvedValue([
3434
{
3535
_id: '1',
3636
pluginName: 'Plugin 1',
@@ -47,7 +47,7 @@ jest.mock('components/AddOn/support/services/Plugin.helper', () => ({
4747
},
4848
// Add more mock data as needed
4949
]),
50-
fetchInstalled: jest.fn().mockResolvedValue([
50+
fetchInstalled: vi.fn().mockResolvedValue([
5151
{
5252
_id: '1',
5353
pluginName: 'Installed Plugin 1',
@@ -64,18 +64,16 @@ jest.mock('components/AddOn/support/services/Plugin.helper', () => ({
6464
},
6565
// Add more mock data as needed
6666
]),
67-
generateLinks: jest
68-
.fn()
69-
.mockImplementation((plugins: InterfacePlugin[]) => {
70-
return plugins
71-
.filter((plugin) => plugin.enabled)
72-
.map((installedPlugin) => {
73-
return {
74-
name: installedPlugin.pluginName,
75-
url: `/plugin/${installedPlugin.component.toLowerCase()}`,
76-
};
77-
});
78-
}),
67+
generateLinks: vi.fn().mockImplementation((plugins: InterfacePlugin[]) => {
68+
return plugins
69+
.filter((plugin) => plugin.enabled)
70+
.map((installedPlugin) => {
71+
return {
72+
name: installedPlugin.pluginName,
73+
url: `/plugin/${installedPlugin.component.toLowerCase()}`,
74+
};
75+
});
76+
}),
7977
})),
8078
}));
8179

@@ -99,11 +97,11 @@ const client: ApolloClient<NormalizedCacheObject> = new ApolloClient({
9997
link: ApolloLink.from([httpLink]),
10098
});
10199

102-
jest.mock('components/AddOn/support/services/Plugin.helper', () => ({
100+
vi.mock('components/AddOn/support/services/Plugin.helper', () => ({
103101
__esModule: true,
104-
default: jest.fn().mockImplementation(() => ({
105-
fetchInstalled: jest.fn().mockResolvedValue([]),
106-
fetchStore: jest.fn().mockResolvedValue([]),
102+
default: vi.fn().mockImplementation(() => ({
103+
fetchInstalled: vi.fn().mockResolvedValue([]),
104+
fetchStore: vi.fn().mockResolvedValue([]),
107105
})),
108106
}));
109107

@@ -168,10 +166,15 @@ const PLUGIN_LOADING_MOCK = {
168166
loading: true,
169167
},
170168
};
171-
jest.mock('react-router-dom', () => ({
172-
...jest.requireActual('react-router-dom'),
173-
useParams: () => ({ orgId: 'undefined' }),
174-
}));
169+
170+
vi.mock('react-router-dom', async () => {
171+
const actualModule = await vi.importActual('react-router-dom');
172+
return {
173+
...actualModule,
174+
useParams: () => ({ orgId: 'undefined' }),
175+
};
176+
});
177+
175178
const ORGANIZATIONS_LIST_MOCK = {
176179
request: {
177180
query: ORGANIZATIONS_LIST,

src/components/AddOn/support/components/Action/Action.test.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/components/CheckIn/tagTemplate.ts

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)