Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const createMockPersister = (): Persister => {
let storedState: PersistedClient | undefined

return {
async persistClient(persistClient: PersistedClient) {
persistClient(persistClient: PersistedClient) {
storedState = persistClient
},
async restoreClient() {
Expand Down
24 changes: 12 additions & 12 deletions packages/solid-query/src/__tests__/useMutation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,11 @@ describe('useMutation', () => {

function Page() {
const mutation = useMutation(() => ({
mutationFn: async (text: string) => text,
onSuccess: async () => {
mutationFn: (text: string) => Promise.resolve(text),
onSuccess: () => {
callbacks.push('useMutation.onSuccess')
},
onSettled: async () => {
onSettled: () => {
callbacks.push('useMutation.onSettled')
},
}))
Expand All @@ -330,10 +330,10 @@ describe('useMutation', () => {
setActTimeout(async () => {
try {
const result = await mutateAsync('todo', {
onSuccess: async () => {
onSuccess: () => {
callbacks.push('mutateAsync.onSuccess')
},
onSettled: async () => {
onSettled: () => {
callbacks.push('mutateAsync.onSettled')
},
})
Expand Down Expand Up @@ -369,10 +369,10 @@ describe('useMutation', () => {
const mutation = useMutation(() => ({
mutationFn: async (_text: string) => Promise.reject(new Error('oops')),

onError: async () => {
onError: () => {
callbacks.push('useMutation.onError')
},
onSettled: async () => {
onSettled: () => {
callbacks.push('useMutation.onSettled')
},
}))
Expand All @@ -382,10 +382,10 @@ describe('useMutation', () => {
setActTimeout(async () => {
try {
await mutateAsync('todo', {
onError: async () => {
onError: () => {
callbacks.push('mutateAsync.onError')
},
onSettled: async () => {
onSettled: () => {
callbacks.push('mutateAsync.onSettled')
},
})
Expand Down Expand Up @@ -756,7 +756,7 @@ describe('useMutation', () => {
})
})

it('should not change state if unmounted', async () => {
it('should not change state if unmounted', () => {
function Mutates() {
const mutation = useMutation(() => ({ mutationFn: () => sleep(10) }))
return <button onClick={() => mutation.mutate()}>mutate</button>
Expand Down Expand Up @@ -901,11 +901,11 @@ describe('useMutation', () => {

function Page() {
const mutationSucceed = useMutation(() => ({
mutationFn: async () => '',
mutationFn: () => Promise.resolve(''),
meta: { metaSuccessMessage },
}))
const mutationError = useMutation(() => ({
mutationFn: async () => {
mutationFn: () => {
throw new Error('')
},
meta: { metaErrorMessage },
Expand Down
10 changes: 5 additions & 5 deletions packages/solid-query/src/__tests__/useQueries.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('useQueries', () => {
expect(results[2]).toMatchObject([{ data: 1 }, { data: 2 }])
})

it('handles type parameter - tuple of tuples', async () => {
it('handles type parameter - tuple of tuples', () => {
const key1 = queryKey()
const key2 = queryKey()
const key3 = queryKey()
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('useQueries', () => {
}
})

it('handles type parameter - tuple of objects', async () => {
it('handles type parameter - tuple of objects', () => {
const key1 = queryKey()
const key2 = queryKey()
const key3 = queryKey()
Expand Down Expand Up @@ -315,7 +315,7 @@ describe('useQueries', () => {
}
})

it('handles array literal without type parameter to infer result type', async () => {
it('handles array literal without type parameter to infer result type', () => {
const key1 = queryKey()
const key2 = queryKey()
const key3 = queryKey()
Expand Down Expand Up @@ -544,7 +544,7 @@ describe('useQueries', () => {
type QueryKeyA = ['queryA']
const getQueryKeyA = (): QueryKeyA => ['queryA']
type GetQueryFunctionA = () => QueryFunction<number, QueryKeyA>
const getQueryFunctionA: GetQueryFunctionA = () => async () => {
const getQueryFunctionA: GetQueryFunctionA = () => () => {
return 1
}
type SelectorA = (data: number) => [number, string]
Expand All @@ -553,7 +553,7 @@ describe('useQueries', () => {
type QueryKeyB = ['queryB', string]
const getQueryKeyB = (id: string): QueryKeyB => ['queryB', id]
type GetQueryFunctionB = () => QueryFunction<string, QueryKeyB>
const getQueryFunctionB: GetQueryFunctionB = () => async () => {
const getQueryFunctionB: GetQueryFunctionB = () => () => {
return '1'
}
type SelectorB = (data: string) => [string, number]
Expand Down
28 changes: 14 additions & 14 deletions packages/solid-query/src/__tests__/useQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('useQuery', () => {
// it should provide the result type in the configuration
useQuery(() => ({
queryKey: [key],
queryFn: async () => true,
queryFn: () => true,
}))

// it should be possible to specify a union type as result type
Expand Down Expand Up @@ -117,7 +117,7 @@ describe('useQuery', () => {
type MyData = number
type MyQueryKey = readonly ['my-data', number]

const getMyDataArrayKey: QueryFunction<MyData, MyQueryKey> = async ({
const getMyDataArrayKey: QueryFunction<MyData, MyQueryKey> = ({
queryKey: [, n],
}) => {
return n + 42
Expand All @@ -128,9 +128,7 @@ describe('useQuery', () => {
queryFn: getMyDataArrayKey,
}))

const getMyDataStringKey: QueryFunction<MyData, ['1']> = async (
context,
) => {
const getMyDataStringKey: QueryFunction<MyData, ['1']> = (context) => {
expectTypeOf(context.queryKey).toEqualTypeOf<['1']>()
return Number(context.queryKey[0]) + 42
}
Expand Down Expand Up @@ -170,7 +168,7 @@ describe('useQuery', () => {
queryFn: () => fetcher(qk[1], 'token'),
...options,
}))
const test = useWrappedQuery([''], async () => '1')
const test = useWrappedQuery([''], () => Promise.resolve('1'))
expectTypeOf(test.data).toEqualTypeOf<string | undefined>()

// handles wrapped queries with custom fetcher passed directly to useQuery
Expand All @@ -188,7 +186,9 @@ describe('useQuery', () => {
'safely'
>,
) => useQuery(() => ({ queryKey: qk, queryFn: fetcher, ...options }))
const testFuncStyle = useWrappedFuncStyleQuery([''], async () => true)
const testFuncStyle = useWrappedFuncStyleQuery([''], () =>
Promise.resolve(true),
)
expectTypeOf(testFuncStyle.data).toEqualTypeOf<boolean | undefined>()
}
})
Expand Down Expand Up @@ -1854,7 +1854,7 @@ describe('useQuery', () => {
})

// See https://github.com/tannerlinsley/react-query/issues/137
it('should not override initial data in dependent queries', async () => {
it('should not override initial data in dependent queries', () => {
const key1 = queryKey()
const key2 = queryKey()

Expand Down Expand Up @@ -1895,7 +1895,7 @@ describe('useQuery', () => {
rendered.getByText('Second Status: success')
})

it('should update query options', async () => {
it('should update query options', () => {
const key = queryKey()

const queryFn = async () => {
Expand Down Expand Up @@ -2018,7 +2018,7 @@ describe('useQuery', () => {
})

// See https://github.com/tannerlinsley/react-query/issues/144
it('should be in "pending" state by default', async () => {
it('should be in "pending" state by default', () => {
const key = queryKey()

function Page() {
Expand Down Expand Up @@ -3403,7 +3403,7 @@ describe('useQuery', () => {

const query = useQuery<unknown, Error>(() => ({
queryKey: key,
queryFn: async () => {
queryFn: () => {
if (counter < 2) {
counter++
throw new Error('error')
Expand Down Expand Up @@ -3753,7 +3753,7 @@ describe('useQuery', () => {
expect(results[2]).toMatchObject({ data: 'fetched data', isStale: false })
})

it('should support enabled:false in query object syntax', async () => {
it('should support enabled:false in query object syntax', () => {
const key = queryKey()
const queryFn = vi.fn<(...args: Array<unknown>) => string>()
queryFn.mockImplementation(() => 'data')
Expand Down Expand Up @@ -5916,7 +5916,7 @@ describe('useQuery', () => {
const states: Array<UseQueryResult<unknown>> = []
const error = new Error('oops')

const queryFn = async (): Promise<unknown> => {
const queryFn = (): Promise<unknown> => {
throw error
}

Expand Down Expand Up @@ -5996,7 +5996,7 @@ describe('useQuery', () => {
function Page() {
const state = useQuery(() => ({
queryKey: key,
queryFn: async (): Promise<unknown> => {
queryFn: (): Promise<unknown> => {
throw error
},
retry: false,
Expand Down
Loading