Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored src/components/AddOn/* from jest to Vitest #2917

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 0 additions & 236 deletions src/components/AddOn/core/AddOnEntry/AddOnEntry.test.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { act } from 'react';
import 'jest-location-mock';
import { fireEvent, render, screen } from '@testing-library/react';
import {
ApolloClient,
Expand All @@ -20,17 +19,18 @@ import { ORGANIZATIONS_LIST, PLUGIN_GET } from 'GraphQl/Queries/Queries';
import userEvent from '@testing-library/user-event';
import useLocalStorage from 'utils/useLocalstorage';
import { MockedProvider } from '@apollo/react-testing';
import { vi, describe, test, expect } from 'vitest';

const { getItem } = useLocalStorage();
interface InterfacePlugin {
enabled: boolean;
pluginName: string;
component: string;
}
jest.mock('components/AddOn/support/services/Plugin.helper', () => ({
vi.mock('components/AddOn/support/services/Plugin.helper', () => ({
__esModule: true,
default: jest.fn().mockImplementation(() => ({
fetchStore: jest.fn().mockResolvedValue([
default: vi.fn().mockImplementation(() => ({
fetchStore: vi.fn().mockResolvedValue([
{
_id: '1',
pluginName: 'Plugin 1',
Expand All @@ -47,7 +47,7 @@ jest.mock('components/AddOn/support/services/Plugin.helper', () => ({
},
// Add more mock data as needed
]),
fetchInstalled: jest.fn().mockResolvedValue([
fetchInstalled: vi.fn().mockResolvedValue([
{
_id: '1',
pluginName: 'Installed Plugin 1',
Expand All @@ -64,18 +64,16 @@ jest.mock('components/AddOn/support/services/Plugin.helper', () => ({
},
// Add more mock data as needed
]),
generateLinks: jest
.fn()
.mockImplementation((plugins: InterfacePlugin[]) => {
return plugins
.filter((plugin) => plugin.enabled)
.map((installedPlugin) => {
return {
name: installedPlugin.pluginName,
url: `/plugin/${installedPlugin.component.toLowerCase()}`,
};
});
}),
generateLinks: vi.fn().mockImplementation((plugins: InterfacePlugin[]) => {
return plugins
.filter((plugin) => plugin.enabled)
.map((installedPlugin) => {
return {
name: installedPlugin.pluginName,
url: `/plugin/${installedPlugin.component.toLowerCase()}`,
};
});
}),
})),
}));

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

jest.mock('components/AddOn/support/services/Plugin.helper', () => ({
vi.mock('components/AddOn/support/services/Plugin.helper', () => ({
__esModule: true,
default: jest.fn().mockImplementation(() => ({
fetchInstalled: jest.fn().mockResolvedValue([]),
fetchStore: jest.fn().mockResolvedValue([]),
default: vi.fn().mockImplementation(() => ({
fetchInstalled: vi.fn().mockResolvedValue([]),
fetchStore: vi.fn().mockResolvedValue([]),
})),
}));

Expand Down Expand Up @@ -168,10 +166,15 @@ const PLUGIN_LOADING_MOCK = {
loading: true,
},
};
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useParams: () => ({ orgId: 'undefined' }),
}));

vi.mock('react-router-dom', async () => {
const actualModule = await vi.importActual('react-router-dom');
return {
...actualModule,
useParams: () => ({ orgId: 'undefined' }),
};
});

const ORGANIZATIONS_LIST_MOCK = {
request: {
query: ORGANIZATIONS_LIST,
Expand Down
24 changes: 0 additions & 24 deletions src/components/AddOn/support/components/Action/Action.test.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/CheckIn/tagTemplate.ts

Large diffs are not rendered by default.

Loading