Skip to content
Source
Sign inSign up
TanStack/query

test(react-query/HydrationBoundary): add tests for 'non-object' state and missing 'queries' property handling #9605

Mergedsukvvon(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/9605/headmerged by manudeli(GitHub profile, opens in a new tab)

Showing 1 changed file with 48 additions and 0 deletions.

x
0 of 1 viewed, 1 left
48 additions and 0 deletionspackages/react-query/src/__tests__/HydrationBoundary.test.tsxModified
View file
@@ -362,6 +362,54 @@
queryClient.clear()
​
+ test('should not hydrate queries if state is not an object', async () => {
+ const queryClient = new QueryClient()
+​
+ const hydrateSpy = vi.spyOn(coreModule, 'hydrate')
+​
+ function Page() {
+ return null
+ }
+​
+ render(
+ <QueryClientProvider client={queryClient}>
+ <HydrationBoundary state={'invalid-state' as any}>
+ <Page />
+ </HydrationBoundary>
+ </QueryClientProvider>,
+ )
+​
+ await vi.advanceTimersByTimeAsync(0)
+ expect(hydrateSpy).toHaveBeenCalledTimes(0)
+​
+ hydrateSpy.mockRestore()
+ queryClient.clear()