Skip to content

Commit 86b949b

Browse files
authored
test(solid-query/useQueries): add test for using a provided custom 'queryClient' (#10952)
1 parent 588b30f commit 86b949b

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

packages/solid-query/src/__tests__/useQueries.test.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
it,
88
vi,
99
} from 'vitest'
10-
import { fireEvent } from '@solidjs/testing-library'
10+
import { fireEvent, render } from '@solidjs/testing-library'
1111
import * as QueryCore from '@tanstack/query-core'
1212
import { createRenderEffect, createSignal } from 'solid-js'
1313
import { queryKey, sleep } from '@tanstack/query-test-utils'
@@ -724,6 +724,32 @@ describe('useQueries', () => {
724724
QueriesObserverSpy.mockRestore()
725725
})
726726

727+
it('should use provided custom queryClient', async () => {
728+
const key = queryKey()
729+
const queryFn = () => sleep(10).then(() => 'custom client')
730+
731+
function Page() {
732+
const queries = useQueries(
733+
() => ({
734+
queries: [
735+
{
736+
queryKey: key,
737+
queryFn,
738+
},
739+
],
740+
}),
741+
() => queryClient,
742+
)
743+
744+
return <div>data: {queries[0].data}</div>
745+
}
746+
747+
const rendered = render(() => <Page />)
748+
749+
await vi.advanceTimersByTimeAsync(10)
750+
expect(rendered.getByText('data: custom client')).toBeInTheDocument()
751+
})
752+
727753
it('should not fetch for the duration of the restoring period when isRestoring is true', async () => {
728754
const key1 = queryKey()
729755
const key2 = queryKey()

0 commit comments

Comments
 (0)