Skip to content

Commit 4b368fe

Browse files
Lenz Webermarkerikson
Lenz Weber
authored andcommitted
fix existing tests
1 parent 18113c8 commit 4b368fe

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

packages/toolkit/src/query/tests/buildHooks.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ describe('hooks tests', () => {
199199
expect(screen.getByTestId('isLoading').textContent).toBe('false')
200200
)
201201
// We call a refetch, should still be `false`
202-
act(() => refetch())
202+
act(() => void refetch())
203203
await waitFor(() =>
204204
expect(screen.getByTestId('isFetching').textContent).toBe('true')
205205
)
@@ -255,7 +255,7 @@ describe('hooks tests', () => {
255255
expect(getRenderCount()).toBe(5)
256256

257257
// We call a refetch, should set `isFetching` to true, then false when complete/errored
258-
act(() => refetchMe())
258+
act(() => void refetchMe())
259259
await waitFor(() => {
260260
expect(screen.getByTestId('isLoading').textContent).toBe('false')
261261
expect(screen.getByTestId('isFetching').textContent).toBe('true')

packages/toolkit/src/query/tests/errorHandling.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe('query error handling', () => {
147147
)
148148
)
149149

150-
act(result.current.refetch)
150+
act(() => void result.current.refetch())
151151

152152
await hookWaitFor(() => expect(result.current.isFetching).toBeFalsy())
153153
expect(result.current).toEqual(
@@ -193,7 +193,7 @@ describe('query error handling', () => {
193193
})
194194
)
195195

196-
act(result.current.refetch)
196+
act(() => void result.current.refetch())
197197

198198
await hookWaitFor(() => expect(result.current.isFetching).toBeFalsy())
199199
expect(result.current).toEqual(

packages/toolkit/src/query/tests/unionTypes.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ describe.skip('TS only tests', () => {
346346
}
347347
})
348348

349-
test('queryHookResult (without selector) union', () => {
349+
test('queryHookResult (without selector) union', async () => {
350350
const useQueryStateResult = api.endpoints.test.useQueryState()
351351
const useQueryResult = api.endpoints.test.useQuery()
352352
const useQueryStateWithSelectFromResult = api.endpoints.test.useQueryState(
@@ -356,12 +356,15 @@ describe.skip('TS only tests', () => {
356356
}
357357
)
358358

359-
const { refetch: _omit, ...useQueryResultWithoutMethods } = useQueryResult
359+
const { refetch, ...useQueryResultWithoutMethods } = useQueryResult
360360
expectExactType(useQueryStateResult)(useQueryResultWithoutMethods)
361361
expectExactType(useQueryStateWithSelectFromResult)(
362362
// @ts-expect-error
363363
useQueryResultWithoutMethods
364364
)
365+
expectType<ReturnType<ReturnType<typeof api.endpoints.test.select>>>(
366+
await refetch()
367+
)
365368
})
366369

367370
test('useQueryState (with selectFromResult)', () => {
@@ -394,8 +397,8 @@ describe.skip('TS only tests', () => {
394397
})(result)
395398
})
396399

397-
test('useQuery (with selectFromResult)', () => {
398-
const result = api.endpoints.test.useQuery(undefined, {
400+
test('useQuery (with selectFromResult)', async () => {
401+
const { refetch, ...result } = api.endpoints.test.useQuery(undefined, {
399402
selectFromResult({
400403
data,
401404
isLoading,
@@ -421,8 +424,11 @@ describe.skip('TS only tests', () => {
421424
isFetching: true,
422425
isSuccess: false,
423426
isError: false,
424-
refetch: () => {},
425427
})(result)
428+
429+
expectType<ReturnType<ReturnType<typeof api.endpoints.test.select>>>(
430+
await refetch()
431+
)
426432
})
427433

428434
test('useMutation union', () => {

0 commit comments

Comments
 (0)