File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
packages/query-core/src/__tests__ Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -415,6 +415,24 @@ describe('queryClient', () => {
415415 } )
416416 } )
417417
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+
418436 describe ( 'getQueryData' , ( ) => {
419437 test ( 'should return the query data if the query is found' , ( ) => {
420438 const key = queryKey ( )
You can’t perform that action at this time.
0 commit comments