Skip to content
Source
Sign inSign up
TanStack/query

fix(react-query): ensureSuspenseTimers should ALWAYS set staleTime to 1000 when it is below 1000. #8398

Mergedminseong0324(GitHub profile, opens in a new tab)merged 11 commits intomain fromrefs/pull/8398/headmerged by TkDodo View on GitHub

Showing 3 changed files with 194 additions and 0 deletions (loading 2).

x
0 of 3 viewed, 3 left
194 additions and 0 deletionspackages/react-query/src/__tests__/suspense.test.tsxAdded
View file
@@ -0,0 +1,194 @@
+import { act, render, waitFor } from '@testing-library/react'
+import { Suspense } from 'react'
+import {
+ afterAll,
+ beforeAll,
+ beforeEach,
+ describe,
+ expect,
+ it,
+ vi,
+} from 'vitest'
+import { QueryClient, QueryClientProvider, useSuspenseQuery } from '..'
+import { queryKey } from './utils'
+import type { QueryKey } from '..'
+​
+function renderWithSuspense(client: QueryClient, ui: React.ReactNode) {
+ return render(
+ <QueryClientProvider client={client}>
+ <Suspense fallback="loading">{ui}</Suspense>
+ </QueryClientProvider>,
+ )
+}
+​
+function createTestQuery(options: {
+ fetchCount: { count: number }
+ queryKey: QueryKey
+ staleTime?: number | (() => number)