import { type UseMutateAsyncFunction, type UseMutateFunction, type UseMutationResult, useMutation, } from '@tanstack/react-query' import { describe, expectTypeOf, it } from 'vitest' import { Mutation } from './Mutation' import { mutationOptions } from './mutationOptions' const mutationOption = mutationOptions({ mutationFn: () => Promise.resolve(1), onMutate: () => 'onMutation', }) describe('mutationOptions', () => { it('should be used with useMutation', () => { const mutation = useMutation(mutationOption) expectTypeOf(mutation).toEqualTypeOf>() expectTypeOf(mutation.data).toEqualTypeOf() expectTypeOf(mutation.mutate).toEqualTypeOf>() expectTypeOf(mutation.mutateAsync).toEqualTypeOf>() }) it('should be used with ', () => { ;(() => ( {(mutation) => { expectTypeOf(mutation).toEqualTypeOf>() expectTypeOf(mutation.data).toEqualTypeOf() return <> }} ))() }) })