@@ -17,16 +17,17 @@ import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
17
17
import useLocalStorage from 'utils/useLocalstorage' ;
18
18
import { props } from './EventListCardProps' ;
19
19
import { ERROR_MOCKS , MOCKS } from './EventListCardMocks' ;
20
+ import { vi , beforeAll , afterAll , expect , it } from 'vitest' ;
20
21
21
22
const { setItem } = useLocalStorage ( ) ;
22
23
23
24
const link = new StaticMockLink ( MOCKS , true ) ;
24
25
const link2 = new StaticMockLink ( ERROR_MOCKS , true ) ;
25
26
26
- jest . mock ( 'react-toastify' , ( ) => ( {
27
+ vi . mock ( 'react-toastify' , ( ) => ( {
27
28
toast : {
28
- success : jest . fn ( ) ,
29
- error : jest . fn ( ) ,
29
+ success : vi . fn ( ) ,
30
+ error : vi . fn ( ) ,
30
31
} ,
31
32
} ) ) ;
32
33
@@ -101,18 +102,17 @@ describe('Testing Event List Card', () => {
101
102
} ;
102
103
103
104
beforeAll ( ( ) => {
104
- jest . mock ( 'react-router-dom' , ( ) => ( {
105
- ...jest . requireActual ( 'react-router-dom' ) ,
106
- useParams : ( ) => ( { orgId : 'orgId' } ) ,
105
+ vi . mock ( 'react-router-dom' , async ( ) => ( {
106
+ ...( await vi . importActual ( 'react-router-dom' ) ) ,
107
107
} ) ) ;
108
108
} ) ;
109
109
110
110
afterAll ( ( ) => {
111
111
localStorage . clear ( ) ;
112
- jest . clearAllMocks ( ) ;
112
+ vi . clearAllMocks ( ) ;
113
113
} ) ;
114
114
115
- test ( 'Testing for event modal' , async ( ) => {
115
+ it ( 'Testing for event modal' , async ( ) => {
116
116
renderEventListCard ( props [ 1 ] ) ;
117
117
118
118
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
@@ -129,7 +129,7 @@ describe('Testing Event List Card', () => {
129
129
} ) ;
130
130
} ) ;
131
131
132
- test ( 'Should navigate to "/" if orgId is not defined' , async ( ) => {
132
+ it ( 'Should navigate to "/" if orgId is not defined' , async ( ) => {
133
133
render (
134
134
< MockedProvider addTypename = { false } link = { link } >
135
135
< I18nextProvider i18n = { i18n } >
@@ -163,15 +163,15 @@ describe('Testing Event List Card', () => {
163
163
} ) ;
164
164
} ) ;
165
165
166
- test ( 'Should render default text if event details are null' , async ( ) => {
166
+ it ( 'Should render default text if event details are null' , async ( ) => {
167
167
renderEventListCard ( props [ 0 ] ) ;
168
168
169
169
await waitFor ( ( ) => {
170
170
expect ( screen . getByText ( 'Dogs Care' ) ) . toBeInTheDocument ( ) ;
171
171
} ) ;
172
172
} ) ;
173
173
174
- test ( 'should render props and text elements test for the screen' , async ( ) => {
174
+ it ( 'should render props and text elements test for the screen' , async ( ) => {
175
175
renderEventListCard ( props [ 1 ] ) ;
176
176
177
177
expect ( screen . getByText ( props [ 1 ] . eventName ) ) . toBeInTheDocument ( ) ;
@@ -198,7 +198,7 @@ describe('Testing Event List Card', () => {
198
198
} ) ;
199
199
} ) ;
200
200
201
- test ( 'Should render truncated event name when length is more than 100' , async ( ) => {
201
+ it ( 'Should render truncated event name when length is more than 100' , async ( ) => {
202
202
const longEventName = 'a' . repeat ( 101 ) ;
203
203
renderEventListCard ( { ...props [ 1 ] , eventName : longEventName } ) ;
204
204
@@ -221,7 +221,7 @@ describe('Testing Event List Card', () => {
221
221
} ) ;
222
222
} ) ;
223
223
224
- test ( 'Should render full event name when length is less than or equal to 100' , async ( ) => {
224
+ it ( 'Should render full event name when length is less than or equal to 100' , async ( ) => {
225
225
const shortEventName = 'a' . repeat ( 100 ) ;
226
226
renderEventListCard ( { ...props [ 1 ] , eventName : shortEventName } ) ;
227
227
@@ -242,7 +242,7 @@ describe('Testing Event List Card', () => {
242
242
} ) ;
243
243
} ) ;
244
244
245
- test ( 'Should render truncated event description when length is more than 256' , async ( ) => {
245
+ it ( 'Should render truncated event description when length is more than 256' , async ( ) => {
246
246
const longEventDescription = 'a' . repeat ( 257 ) ;
247
247
248
248
renderEventListCard ( {
@@ -268,7 +268,7 @@ describe('Testing Event List Card', () => {
268
268
} ) ;
269
269
} ) ;
270
270
271
- test ( 'Should render full event description when length is less than or equal to 256' , async ( ) => {
271
+ it ( 'Should render full event description when length is less than or equal to 256' , async ( ) => {
272
272
const shortEventDescription = 'a' . repeat ( 256 ) ;
273
273
274
274
renderEventListCard ( {
@@ -294,7 +294,7 @@ describe('Testing Event List Card', () => {
294
294
} ) ;
295
295
} ) ;
296
296
297
- test ( 'Should navigate to event dashboard when clicked (For Admin)' , async ( ) => {
297
+ it ( 'Should navigate to event dashboard when clicked (For Admin)' , async ( ) => {
298
298
renderEventListCard ( props [ 1 ] ) ;
299
299
300
300
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
@@ -311,7 +311,7 @@ describe('Testing Event List Card', () => {
311
311
} ) ;
312
312
} ) ;
313
313
314
- test ( 'Should navigate to event dashboard when clicked (For User)' , async ( ) => {
314
+ it ( 'Should navigate to event dashboard when clicked (For User)' , async ( ) => {
315
315
setItem ( 'userId' , '123' ) ;
316
316
renderEventListCard ( props [ 2 ] ) ;
317
317
@@ -329,7 +329,7 @@ describe('Testing Event List Card', () => {
329
329
} ) ;
330
330
} ) ;
331
331
332
- test ( 'Should update a non-recurring event' , async ( ) => {
332
+ it ( 'Should update a non-recurring event' , async ( ) => {
333
333
renderEventListCard ( props [ 1 ] ) ;
334
334
335
335
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
@@ -372,7 +372,7 @@ describe('Testing Event List Card', () => {
372
372
} ) ;
373
373
} ) ;
374
374
375
- test ( 'Should update a non all day non-recurring event' , async ( ) => {
375
+ it ( 'Should update a non all day non-recurring event' , async ( ) => {
376
376
renderEventListCard ( props [ 1 ] ) ;
377
377
378
378
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
@@ -425,7 +425,7 @@ describe('Testing Event List Card', () => {
425
425
} ) ;
426
426
} ) ;
427
427
428
- test ( 'should update a single event to be recurring' , async ( ) => {
428
+ it ( 'should update a single event to be recurring' , async ( ) => {
429
429
renderEventListCard ( props [ 1 ] ) ;
430
430
431
431
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
@@ -469,7 +469,7 @@ describe('Testing Event List Card', () => {
469
469
} ) ;
470
470
} ) ;
471
471
472
- test ( 'should show different update options for a recurring event based on different conditions' , async ( ) => {
472
+ it ( 'should show different update options for a recurring event based on different conditions' , async ( ) => {
473
473
renderEventListCard ( props [ 5 ] ) ;
474
474
475
475
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
@@ -595,7 +595,7 @@ describe('Testing Event List Card', () => {
595
595
} ) ;
596
596
} ) ;
597
597
598
- test ( 'should show recurrenceRule as changed if the recurrence weekdays have changed' , async ( ) => {
598
+ it ( 'should show recurrenceRule as changed if the recurrence weekdays have changed' , async ( ) => {
599
599
renderEventListCard ( props [ 4 ] ) ;
600
600
601
601
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
@@ -656,7 +656,7 @@ describe('Testing Event List Card', () => {
656
656
} ) ;
657
657
} ) ;
658
658
659
- test ( 'should update all instances of a recurring event' , async ( ) => {
659
+ it ( 'should update all instances of a recurring event' , async ( ) => {
660
660
renderEventListCard ( props [ 6 ] ) ;
661
661
662
662
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
@@ -706,7 +706,7 @@ describe('Testing Event List Card', () => {
706
706
} ) ;
707
707
} ) ;
708
708
709
- test ( 'should update thisAndFollowingInstances of a recurring event' , async ( ) => {
709
+ it ( 'should update thisAndFollowingInstances of a recurring event' , async ( ) => {
710
710
renderEventListCard ( props [ 5 ] ) ;
711
711
712
712
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
@@ -772,7 +772,7 @@ describe('Testing Event List Card', () => {
772
772
} ) ;
773
773
} ) ;
774
774
775
- test ( 'should render the delete modal' , async ( ) => {
775
+ it ( 'should render the delete modal' , async ( ) => {
776
776
renderEventListCard ( props [ 1 ] ) ;
777
777
778
778
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
@@ -807,7 +807,7 @@ describe('Testing Event List Card', () => {
807
807
} ) ;
808
808
} ) ;
809
809
810
- test ( 'should call the delete event mutation when the "Yes" button is clicked' , async ( ) => {
810
+ it ( 'should call the delete event mutation when the "Yes" button is clicked' , async ( ) => {
811
811
renderEventListCard ( props [ 1 ] ) ;
812
812
813
813
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
@@ -833,7 +833,7 @@ describe('Testing Event List Card', () => {
833
833
} ) ;
834
834
} ) ;
835
835
836
- test ( 'select different delete options on recurring events & then delete the recurring event' , async ( ) => {
836
+ it ( 'select different delete options on recurring events & then delete the recurring event' , async ( ) => {
837
837
renderEventListCard ( props [ 4 ] ) ;
838
838
839
839
await wait ( ) ;
@@ -873,7 +873,7 @@ describe('Testing Event List Card', () => {
873
873
} ) ;
874
874
} ) ;
875
875
876
- test ( 'should show an error toast when the delete event mutation fails' , async ( ) => {
876
+ it ( 'should show an error toast when the delete event mutation fails' , async ( ) => {
877
877
// Destructure key from props[1] and pass it separately to avoid spreading it
878
878
const { key, ...otherProps } = props [ 1 ] ;
879
879
render (
@@ -908,7 +908,7 @@ describe('Testing Event List Card', () => {
908
908
} ) ;
909
909
} ) ;
910
910
911
- test ( 'handle register should work properly' , async ( ) => {
911
+ it ( 'handle register should work properly' , async ( ) => {
912
912
setItem ( 'userId' , '456' ) ;
913
913
914
914
renderEventListCard ( props [ 2 ] ) ;
@@ -933,7 +933,7 @@ describe('Testing Event List Card', () => {
933
933
} ) ;
934
934
} ) ;
935
935
936
- test ( 'should show already registered text when the user is registered for an event' , async ( ) => {
936
+ it ( 'should show already registered text when the user is registered for an event' , async ( ) => {
937
937
renderEventListCard ( props [ 3 ] ) ;
938
938
939
939
userEvent . click ( screen . getByTestId ( 'card' ) ) ;
0 commit comments