1
1
import React , { act } from 'react' ;
2
- import 'jest-location-mock' ;
3
2
import { fireEvent , render , screen } from '@testing-library/react' ;
4
3
import {
5
4
ApolloClient ,
@@ -20,17 +19,18 @@ import { ORGANIZATIONS_LIST, PLUGIN_GET } from 'GraphQl/Queries/Queries';
20
19
import userEvent from '@testing-library/user-event' ;
21
20
import useLocalStorage from 'utils/useLocalstorage' ;
22
21
import { MockedProvider } from '@apollo/react-testing' ;
22
+ import { vi , describe , test , expect } from 'vitest' ;
23
23
24
24
const { getItem } = useLocalStorage ( ) ;
25
25
interface InterfacePlugin {
26
26
enabled : boolean ;
27
27
pluginName : string ;
28
28
component : string ;
29
29
}
30
- jest . mock ( 'components/AddOn/support/services/Plugin.helper' , ( ) => ( {
30
+ vi . mock ( 'components/AddOn/support/services/Plugin.helper' , ( ) => ( {
31
31
__esModule : true ,
32
- default : jest . fn ( ) . mockImplementation ( ( ) => ( {
33
- fetchStore : jest . fn ( ) . mockResolvedValue ( [
32
+ default : vi . fn ( ) . mockImplementation ( ( ) => ( {
33
+ fetchStore : vi . fn ( ) . mockResolvedValue ( [
34
34
{
35
35
_id : '1' ,
36
36
pluginName : 'Plugin 1' ,
@@ -47,7 +47,7 @@ jest.mock('components/AddOn/support/services/Plugin.helper', () => ({
47
47
} ,
48
48
// Add more mock data as needed
49
49
] ) ,
50
- fetchInstalled : jest . fn ( ) . mockResolvedValue ( [
50
+ fetchInstalled : vi . fn ( ) . mockResolvedValue ( [
51
51
{
52
52
_id : '1' ,
53
53
pluginName : 'Installed Plugin 1' ,
@@ -64,18 +64,16 @@ jest.mock('components/AddOn/support/services/Plugin.helper', () => ({
64
64
} ,
65
65
// Add more mock data as needed
66
66
] ) ,
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
+ } ) ,
79
77
} ) ) ,
80
78
} ) ) ;
81
79
@@ -99,11 +97,11 @@ const client: ApolloClient<NormalizedCacheObject> = new ApolloClient({
99
97
link : ApolloLink . from ( [ httpLink ] ) ,
100
98
} ) ;
101
99
102
- jest . mock ( 'components/AddOn/support/services/Plugin.helper' , ( ) => ( {
100
+ vi . mock ( 'components/AddOn/support/services/Plugin.helper' , ( ) => ( {
103
101
__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 ( [ ] ) ,
107
105
} ) ) ,
108
106
} ) ) ;
109
107
@@ -168,10 +166,15 @@ const PLUGIN_LOADING_MOCK = {
168
166
loading : true ,
169
167
} ,
170
168
} ;
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
+
175
178
const ORGANIZATIONS_LIST_MOCK = {
176
179
request : {
177
180
query : ORGANIZATIONS_LIST ,
0 commit comments