Skip to content
Open
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
11 changes: 5 additions & 6 deletions packages/solid-query/src/__tests__/QueryClientProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('QueryClientProvider', () => {
await vi.advanceTimersByTimeAsync(10)
expect(rendered.getByText('test')).toBeInTheDocument()

expect(queryCache.find({ queryKey: key })).toBeDefined()
expect(queryCache.find({ queryKey: key })?.state.data).toBe('test')
})

it('allows multiple caches to be partitioned', async () => {
Expand Down Expand Up @@ -94,10 +94,10 @@ describe('QueryClientProvider', () => {
expect(rendered.getByText('test1')).toBeInTheDocument()
expect(rendered.getByText('test2')).toBeInTheDocument()

expect(queryCache1.find({ queryKey: key1 })).toBeDefined()
expect(queryCache1.find({ queryKey: key2 })).not.toBeDefined()
expect(queryCache2.find({ queryKey: key1 })).not.toBeDefined()
expect(queryCache2.find({ queryKey: key2 })).toBeDefined()
expect(queryCache1.find({ queryKey: key1 })?.state.data).toBe('test1')
expect(queryCache1.find({ queryKey: key2 })).toBeUndefined()
expect(queryCache2.find({ queryKey: key1 })).toBeUndefined()
expect(queryCache2.find({ queryKey: key2 })?.state.data).toBe('test2')
})

it("uses defaultOptions for queries when they don't provide their own config", async () => {
Expand Down Expand Up @@ -135,7 +135,6 @@ describe('QueryClientProvider', () => {
await vi.advanceTimersByTimeAsync(10)
expect(rendered.getByText('test')).toBeInTheDocument()

expect(queryCache.find({ queryKey: key })).toBeDefined()
expect(queryCache.find({ queryKey: key })?.options.gcTime).toBe(Infinity)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,5 @@ describe('mutationOptions', () => {
const lastSnapshot = mutationStateArray[mutationStateArray.length - 1]!
expect(lastSnapshot.length).toEqual(1)
expect(lastSnapshot[0]?.data).toEqual('data1')
expect(lastSnapshot[1]).toBeFalsy()
})
})
2 changes: 1 addition & 1 deletion packages/solid-query/src/__tests__/suspense.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe("useQuery's in Suspense mode", () => {
const rendered = renderWithClient(queryClient, () => <App />)

expect(rendered.queryByText('rendered')).not.toBeInTheDocument()
expect(queryCache.find({ queryKey: key })).toBeFalsy()
expect(queryCache.find({ queryKey: key })).toBeUndefined()

fireEvent.click(rendered.getByLabelText('toggle'))
await vi.advanceTimersByTimeAsync(10)
Expand Down
4 changes: 3 additions & 1 deletion packages/solid-query/src/__tests__/useQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5746,7 +5746,9 @@ describe('useQuery', () => {
await vi.advanceTimersByTimeAsync(10)

expect(rendered.getByText('status: success')).toBeInTheDocument()
expect(queryClient1.getQueryCache().find({ queryKey: key })).toBeDefined()
expect(
queryClient1.getQueryCache().find({ queryKey: key })?.state.data,
).toBe('data')
expect(queryFn).toHaveBeenCalledTimes(1)

setClient(queryClient2)
Expand Down