Skip to content

Commit 77e3cd8

Browse files
test(solid-query): assert queryFn never invoked when data preloaded
Address CodeRabbit nitpick on PR #10592: spy on Page's queryFn and assert it was never called, strengthening the guarantee that the background refetch did not run when data was preloaded via ensureQueryData. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4d23e82 commit 77e3cd8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,11 +921,12 @@ describe("useQuery's in Suspense mode", () => {
921921
await ensurePromise
922922

923923
let fallbackMounted = false
924+
const pageQueryFn = vi.fn(() => sleep(10).then(() => 'fresh'))
924925

925926
function Page() {
926927
const state = useQuery(() => ({
927928
queryKey: key,
928-
queryFn: () => sleep(10).then(() => 'fresh'),
929+
queryFn: pageQueryFn,
929930
staleTime: Infinity,
930931
}))
931932

@@ -947,6 +948,7 @@ describe("useQuery's in Suspense mode", () => {
947948

948949
expect(rendered.getByText('data: preloaded')).toBeInTheDocument()
949950
expect(fallbackMounted).toBe(false)
951+
expect(pageQueryFn).not.toHaveBeenCalled()
950952
})
951953

952954
it('should render the correct amount of times in Suspense mode when gcTime is set to 0', async () => {

0 commit comments

Comments
 (0)