@@ -4,10 +4,12 @@ import { useIsMutating, useMutationState } from '../useMutationState'
44import { useMutation } from '../useMutation'
55import {
66 createQueryClient ,
7+ doNotExecute ,
78 renderWithClient ,
89 setActTimeout ,
910 sleep ,
1011} from './utils'
12+ import type { MutationState , MutationStatus } from '@tanstack/query-core'
1113
1214describe ( 'useIsMutating' , ( ) => {
1315 it ( 'should return the number of fetching mutations' , async ( ) => {
@@ -172,6 +174,27 @@ describe('useIsMutating', () => {
172174} )
173175
174176describe ( 'useMutationState' , ( ) => {
177+ describe ( 'types' , ( ) => {
178+ it ( 'should default to QueryState' , ( ) => {
179+ doNotExecute ( ( ) => {
180+ const result = useMutationState ( {
181+ filters : { status : 'pending' } ,
182+ } )
183+
184+ expectTypeOf ( result ) . toEqualTypeOf < Array < MutationState > > ( )
185+ } )
186+ } )
187+ it ( 'should infer with select' , ( ) => {
188+ doNotExecute ( ( ) => {
189+ const result = useMutationState ( {
190+ filters : { status : 'pending' } ,
191+ select : ( mutation ) => mutation . state . status ,
192+ } )
193+
194+ expectTypeOf ( result ) . toEqualTypeOf < Array < MutationStatus > > ( )
195+ } )
196+ } )
197+ } )
175198 it ( 'should return variables after calling mutate' , async ( ) => {
176199 const queryClient = createQueryClient ( )
177200 const variables : unknown [ ] [ ] = [ ]
0 commit comments