@@ -340,50 +340,43 @@ describe('mutationOptions', () => {
340340 expect ( states . value ) . toEqual ( [ 'data1' ] )
341341 } )
342342
343- it ( 'should work with options getter and be reactive when used with useIsMutating' , async ( ) => {
344- const keyRef = ref ( 'isMutatingGetter2 ' )
345- const mutationOpts = mutationOptions ( {
346- mutationKey : [ 'isMutatingGetter' ] ,
343+ it ( 'should work with getter passed to mutationOptions when used with useIsMutating' , async ( ) => {
344+ const keyRef = ref ( 'isMutatingGetter ' )
345+ const mutationOpts = mutationOptions ( ( ) => ( {
346+ mutationKey : [ keyRef . value ] ,
347347 mutationFn : ( ) => sleep ( 10 ) . then ( ( ) => 'data' ) ,
348- } )
348+ } ) )
349349
350350 const { mutate } = useMutation ( mutationOpts )
351351 mutate ( )
352352
353- const isMutating = useIsMutating ( ( ) => ( {
353+ const isMutating = useIsMutating ( {
354354 mutationKey : [ keyRef . value ] ,
355- } ) )
356-
357- expect ( isMutating . value ) . toEqual ( 0 )
358-
359- keyRef . value = 'isMutatingGetter'
355+ } )
360356
361357 await vi . advanceTimersByTimeAsync ( 0 )
362-
363358 expect ( isMutating . value ) . toEqual ( 1 )
359+
360+ await vi . advanceTimersByTimeAsync ( 10 )
361+ expect ( isMutating . value ) . toEqual ( 0 )
364362 } )
365363
366- it ( 'should work with options getter and be reactive when used with useMutationState' , async ( ) => {
367- const keyRef = ref ( 'useMutationStateGetter2 ' )
368- const mutationOpts = mutationOptions ( {
369- mutationKey : [ 'useMutationStateGetter' ] ,
364+ it ( 'should work with getter passed to mutationOptions when used with useMutationState' , async ( ) => {
365+ const keyRef = ref ( 'useMutationStateGetter ' )
366+ const mutationOpts = mutationOptions ( ( ) => ( {
367+ mutationKey : [ keyRef . value ] ,
370368 mutationFn : ( params : string ) => sleep ( 10 ) . then ( ( ) => params ) ,
371- } )
369+ } ) )
372370
373371 const { mutate } = useMutation ( mutationOpts )
374372 mutate ( 'foo' )
375373
376- const states = useMutationState ( ( ) => ( {
374+ const states = useMutationState ( {
377375 filters : { mutationKey : [ keyRef . value ] , status : 'pending' } ,
378376 select : ( mutation ) => mutation . state . variables ,
379- } ) )
380-
381- expect ( states . value ) . toEqual ( [ ] )
382-
383- keyRef . value = 'useMutationStateGetter'
377+ } )
384378
385379 await vi . advanceTimersByTimeAsync ( 0 )
386-
387380 expect ( states . value ) . toEqual ( [ 'foo' ] )
388381 } )
389382
0 commit comments