File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
packages/query-core/src/__tests__ Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -397,8 +397,8 @@ describe('mutations', () => {
397
397
const onSuccess = vi . fn ( )
398
398
399
399
const mutation = new MutationObserver ( queryClient , {
400
- mutationFn : ( ) => {
401
- sleep ( 100 )
400
+ mutationFn : async ( ) => {
401
+ await sleep ( 100 )
402
402
return Promise . resolve ( 'update' )
403
403
} ,
404
404
onSuccess : ( ) => {
@@ -409,16 +409,17 @@ describe('mutations', () => {
409
409
void mutation . mutate ( )
410
410
411
411
mutation . setOptions ( {
412
- mutationFn : ( ) => {
413
- sleep ( 100 )
412
+ mutationFn : async ( ) => {
413
+ await sleep ( 100 )
414
414
return Promise . resolve ( 'update' )
415
415
} ,
416
416
onSuccess : ( ) => {
417
417
onSuccess ( 2 )
418
418
} ,
419
419
} )
420
420
421
- await vi . waitFor ( ( ) => expect ( onSuccess ) . toHaveBeenCalledTimes ( 1 ) )
421
+ await vi . advanceTimersByTimeAsync ( 100 )
422
+ expect ( onSuccess ) . toHaveBeenCalledTimes ( 1 )
422
423
423
424
expect ( onSuccess ) . toHaveBeenCalledWith ( 2 )
424
425
} )
You can’t perform that action at this time.
0 commit comments