File tree 1 file changed +18
-0
lines changed
packages/query-core/src/__tests__
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -415,6 +415,24 @@ describe('queryClient', () => {
415
415
} )
416
416
} )
417
417
418
+ describe ( 'isMutating' , ( ) => {
419
+ test ( 'should return length of mutating' , async ( ) => {
420
+ expect ( queryClient . isMutating ( ) ) . toBe ( 0 )
421
+ new MutationObserver ( queryClient , {
422
+ mutationFn : ( ) => sleep ( 10 ) . then ( ( ) => 'data' ) ,
423
+ } ) . mutate ( )
424
+ expect ( queryClient . isMutating ( ) ) . toBe ( 1 )
425
+ new MutationObserver ( queryClient , {
426
+ mutationFn : ( ) => sleep ( 5 ) . then ( ( ) => 'data' ) ,
427
+ } ) . mutate ( )
428
+ expect ( queryClient . isMutating ( ) ) . toBe ( 2 )
429
+ await vi . advanceTimersByTimeAsync ( 5 )
430
+ expect ( queryClient . isMutating ( ) ) . toEqual ( 1 )
431
+ await vi . advanceTimersByTimeAsync ( 5 )
432
+ expect ( queryClient . isMutating ( ) ) . toEqual ( 0 )
433
+ } )
434
+ } )
435
+
418
436
describe ( 'getQueryData' , ( ) => {
419
437
test ( 'should return the query data if the query is found' , ( ) => {
420
438
const key = queryKey ( )
You can’t perform that action at this time.
0 commit comments