@@ -11,7 +11,6 @@ import {
11
11
waitForElementToBeRemoved ,
12
12
} from '@testing-library/react' ;
13
13
import userEvent from '@testing-library/user-event' ;
14
- import 'jest-location-mock' ;
15
14
import { I18nextProvider } from 'react-i18next' ;
16
15
import { Provider } from 'react-redux' ;
17
16
import { MemoryRouter , Route , Routes } from 'react-router-dom' ;
@@ -22,6 +21,7 @@ import i18n from 'utils/i18nForTest';
22
21
import ManageTag from './ManageTag' ;
23
22
import { MOCKS , MOCKS_ERROR_ASSIGNED_MEMBERS } from './ManageTagMocks' ;
24
23
import { type ApolloLink } from '@apollo/client' ;
24
+ import { vi , beforeEach , afterEach , expect , it } from 'vitest' ;
25
25
26
26
const translations = {
27
27
...JSON . parse (
@@ -42,21 +42,21 @@ async function wait(ms = 500): Promise<void> {
42
42
} ) ;
43
43
}
44
44
45
- jest . mock ( 'react-toastify' , ( ) => ( {
45
+ vi . mock ( 'react-toastify' , ( ) => ( {
46
46
toast : {
47
- success : jest . fn ( ) ,
48
- info : jest . fn ( ) ,
49
- error : jest . fn ( ) ,
47
+ success : vi . fn ( ) ,
48
+ info : vi . fn ( ) ,
49
+ error : vi . fn ( ) ,
50
50
} ,
51
51
} ) ) ;
52
52
53
53
/* eslint-disable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports */
54
- jest . mock ( '../../components/AddPeopleToTag/AddPeopleToTag' , ( ) => {
55
- return require ( './ManageTagMockComponents/MockAddPeopleToTag' ) . default ;
54
+ vi . mock ( '../../components/AddPeopleToTag/AddPeopleToTag' , async ( ) => {
55
+ return await import ( './ManageTagMockComponents/MockAddPeopleToTag' ) ;
56
56
} ) ;
57
57
58
- jest . mock ( '../../components/TagActions/TagActions' , ( ) => {
59
- return require ( './ManageTagMockComponents/MockTagActions' ) . default ;
58
+ vi . mock ( '../../components/TagActions/TagActions' , async ( ) => {
59
+ return await import ( './ManageTagMockComponents/MockTagActions' ) ;
60
60
} ) ;
61
61
/* eslint-enable @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports */
62
62
@@ -93,18 +93,17 @@ const renderManageTag = (link: ApolloLink): RenderResult => {
93
93
94
94
describe ( 'Manage Tag Page' , ( ) => {
95
95
beforeEach ( ( ) => {
96
- jest . mock ( 'react-router-dom' , ( ) => ( {
97
- ...jest . requireActual ( 'react-router-dom' ) ,
98
- useParams : ( ) => ( { orgId : 'orgId' } ) ,
96
+ vi . mock ( 'react-router-dom' , async ( ) => ( {
97
+ ...( await vi . importActual ( 'react-router-dom' ) ) ,
99
98
} ) ) ;
100
99
} ) ;
101
100
102
101
afterEach ( ( ) => {
103
- jest . clearAllMocks ( ) ;
102
+ vi . clearAllMocks ( ) ;
104
103
cleanup ( ) ;
105
104
} ) ;
106
105
107
- test ( 'Component loads correctly' , async ( ) => {
106
+ it ( 'Component loads correctly' , async ( ) => {
108
107
const { getByText } = renderManageTag ( link ) ;
109
108
110
109
await wait ( ) ;
@@ -114,7 +113,7 @@ describe('Manage Tag Page', () => {
114
113
} ) ;
115
114
} ) ;
116
115
117
- test ( 'renders error component on unsuccessful userTag assigned members query' , async ( ) => {
116
+ it ( 'renders error component on unsuccessful userTag assigned members query' , async ( ) => {
118
117
const { queryByText } = renderManageTag ( link2 ) ;
119
118
120
119
await wait ( ) ;
@@ -124,7 +123,7 @@ describe('Manage Tag Page', () => {
124
123
} ) ;
125
124
} ) ;
126
125
127
- test ( 'opens and closes the add people to tag modal' , async ( ) => {
126
+ it ( 'opens and closes the add people to tag modal' , async ( ) => {
128
127
renderManageTag ( link ) ;
129
128
130
129
await waitFor ( ( ) => {
@@ -146,7 +145,7 @@ describe('Manage Tag Page', () => {
146
145
} ) ;
147
146
} ) ;
148
147
149
- test ( 'opens and closes the unassign tag modal' , async ( ) => {
148
+ it ( 'opens and closes the unassign tag modal' , async ( ) => {
150
149
renderManageTag ( link ) ;
151
150
152
151
await wait ( ) ;
@@ -168,7 +167,7 @@ describe('Manage Tag Page', () => {
168
167
) ;
169
168
} ) ;
170
169
171
- test ( 'opens and closes the assignToTags modal' , async ( ) => {
170
+ it ( 'opens and closes the assignToTags modal' , async ( ) => {
172
171
renderManageTag ( link ) ;
173
172
174
173
// Wait for the assignToTags button to be present
@@ -193,7 +192,7 @@ describe('Manage Tag Page', () => {
193
192
} ) ;
194
193
} ) ;
195
194
196
- test ( 'opens and closes the removeFromTags modal' , async ( ) => {
195
+ it ( 'opens and closes the removeFromTags modal' , async ( ) => {
197
196
renderManageTag ( link ) ;
198
197
199
198
// Wait for the removeFromTags button to be present
@@ -218,7 +217,7 @@ describe('Manage Tag Page', () => {
218
217
} ) ;
219
218
} ) ;
220
219
221
- test ( 'opens and closes the edit tag modal' , async ( ) => {
220
+ it ( 'opens and closes the edit tag modal' , async ( ) => {
222
221
renderManageTag ( link ) ;
223
222
224
223
await wait ( ) ;
@@ -240,7 +239,7 @@ describe('Manage Tag Page', () => {
240
239
) ;
241
240
} ) ;
242
241
243
- test ( 'opens and closes the remove tag modal' , async ( ) => {
242
+ it ( 'opens and closes the remove tag modal' , async ( ) => {
244
243
renderManageTag ( link ) ;
245
244
246
245
await wait ( ) ;
@@ -262,7 +261,7 @@ describe('Manage Tag Page', () => {
262
261
) ;
263
262
} ) ;
264
263
265
- test ( "navigates to the member's profile after clicking the view option" , async ( ) => {
264
+ it ( "navigates to the member's profile after clicking the view option" , async ( ) => {
266
265
renderManageTag ( link ) ;
267
266
268
267
await wait ( ) ;
@@ -277,7 +276,7 @@ describe('Manage Tag Page', () => {
277
276
} ) ;
278
277
} ) ;
279
278
280
- test ( 'navigates to the subTags screen after clicking the subTags option' , async ( ) => {
279
+ it ( 'navigates to the subTags screen after clicking the subTags option' , async ( ) => {
281
280
renderManageTag ( link ) ;
282
281
283
282
await wait ( ) ;
@@ -292,7 +291,7 @@ describe('Manage Tag Page', () => {
292
291
} ) ;
293
292
} ) ;
294
293
295
- test ( 'navigates to the manageTag screen after clicking a tag in the breadcrumbs' , async ( ) => {
294
+ it ( 'navigates to the manageTag screen after clicking a tag in the breadcrumbs' , async ( ) => {
296
295
renderManageTag ( link ) ;
297
296
298
297
await wait ( ) ;
@@ -309,7 +308,7 @@ describe('Manage Tag Page', () => {
309
308
} ) ;
310
309
} ) ;
311
310
312
- test ( 'navigates to organization tags screen screen after clicking tha all tags option in the breadcrumbs' , async ( ) => {
311
+ it ( 'navigates to organization tags screen screen after clicking tha all tags option in the breadcrumbs' , async ( ) => {
313
312
renderManageTag ( link ) ;
314
313
315
314
await wait ( ) ;
@@ -324,7 +323,7 @@ describe('Manage Tag Page', () => {
324
323
} ) ;
325
324
} ) ;
326
325
327
- test ( 'searchs for tags where the name matches the provided search input' , async ( ) => {
326
+ it ( 'searchs for tags where the name matches the provided search input' , async ( ) => {
328
327
renderManageTag ( link ) ;
329
328
330
329
await wait ( ) ;
@@ -345,7 +344,7 @@ describe('Manage Tag Page', () => {
345
344
} ) ;
346
345
} ) ;
347
346
348
- test ( 'fetches the tags by the sort order, i.e. latest or oldest first' , async ( ) => {
347
+ it ( 'fetches the tags by the sort order, i.e. latest or oldest first' , async ( ) => {
349
348
renderManageTag ( link ) ;
350
349
351
350
await wait ( ) ;
@@ -402,7 +401,7 @@ describe('Manage Tag Page', () => {
402
401
} ) ;
403
402
} ) ;
404
403
405
- test ( 'Fetches more assigned members with infinite scroll' , async ( ) => {
404
+ it ( 'Fetches more assigned members with infinite scroll' , async ( ) => {
406
405
const { getByText } = renderManageTag ( link ) ;
407
406
408
407
await wait ( ) ;
@@ -433,7 +432,7 @@ describe('Manage Tag Page', () => {
433
432
} ) ;
434
433
} ) ;
435
434
436
- test ( 'unassigns a tag from a member' , async ( ) => {
435
+ it ( 'unassigns a tag from a member' , async ( ) => {
437
436
renderManageTag ( link ) ;
438
437
439
438
await wait ( ) ;
@@ -452,7 +451,7 @@ describe('Manage Tag Page', () => {
452
451
} ) ;
453
452
} ) ;
454
453
455
- test ( 'successfully edits the tag name' , async ( ) => {
454
+ it ( 'successfully edits the tag name' , async ( ) => {
456
455
renderManageTag ( link ) ;
457
456
458
457
await wait ( ) ;
@@ -482,7 +481,7 @@ describe('Manage Tag Page', () => {
482
481
} ) ;
483
482
} ) ;
484
483
485
- test ( 'successfully removes the tag and redirects to orgTags page' , async ( ) => {
484
+ it ( 'successfully removes the tag and redirects to orgTags page' , async ( ) => {
486
485
renderManageTag ( link ) ;
487
486
488
487
await wait ( ) ;
0 commit comments