@tanstack/react-query 4.24.9 → 5.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/HydrationBoundary.d.ts +9 -0
- package/build/lib/{Hydrate.esm.js → HydrationBoundary.esm.js} +14 -17
- package/build/lib/HydrationBoundary.esm.js.map +1 -0
- package/build/lib/{Hydrate.js → HydrationBoundary.js} +17 -24
- package/build/lib/HydrationBoundary.js.map +1 -0
- package/build/lib/{Hydrate.mjs → HydrationBoundary.mjs} +14 -17
- package/build/lib/HydrationBoundary.mjs.map +1 -0
- package/build/lib/QueryClientProvider.d.ts +4 -19
- package/build/lib/QueryClientProvider.esm.js +11 -46
- package/build/lib/QueryClientProvider.esm.js.map +1 -1
- package/build/lib/QueryClientProvider.js +14 -52
- package/build/lib/QueryClientProvider.js.map +1 -1
- package/build/lib/QueryClientProvider.mjs +11 -46
- package/build/lib/QueryClientProvider.mjs.map +1 -1
- package/build/lib/QueryErrorResetBoundary.esm.js +7 -2
- package/build/lib/QueryErrorResetBoundary.esm.js.map +1 -1
- package/build/lib/QueryErrorResetBoundary.js +10 -8
- package/build/lib/QueryErrorResetBoundary.js.map +1 -1
- package/build/lib/QueryErrorResetBoundary.mjs +7 -2
- package/build/lib/QueryErrorResetBoundary.mjs.map +1 -1
- package/build/lib/__tests__/useQuery.types.test.d.ts +1 -2
- package/build/lib/__tests__/utils.d.ts +7 -10
- package/build/lib/errorBoundaryUtils.d.ts +3 -3
- package/build/lib/errorBoundaryUtils.esm.js +3 -3
- package/build/lib/errorBoundaryUtils.esm.js.map +1 -1
- package/build/lib/errorBoundaryUtils.js +6 -9
- package/build/lib/errorBoundaryUtils.js.map +1 -1
- package/build/lib/errorBoundaryUtils.mjs +3 -3
- package/build/lib/errorBoundaryUtils.mjs.map +1 -1
- package/build/lib/index.d.ts +4 -5
- package/build/lib/index.esm.js +3 -4
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +6 -9
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +3 -4
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/isRestoring.esm.js.map +1 -1
- package/build/lib/isRestoring.js +3 -6
- package/build/lib/isRestoring.js.map +1 -1
- package/build/lib/isRestoring.mjs.map +1 -1
- package/build/lib/suspense.esm.js +5 -5
- package/build/lib/suspense.esm.js.map +1 -1
- package/build/lib/suspense.js +5 -7
- package/build/lib/suspense.js.map +1 -1
- package/build/lib/suspense.mjs +5 -5
- package/build/lib/suspense.mjs.map +1 -1
- package/build/lib/types.d.ts +14 -22
- package/build/lib/useBaseQuery.d.ts +2 -2
- package/build/lib/useBaseQuery.esm.js +15 -18
- package/build/lib/useBaseQuery.esm.js.map +1 -1
- package/build/lib/useBaseQuery.js +18 -24
- package/build/lib/useBaseQuery.js.map +1 -1
- package/build/lib/useBaseQuery.mjs +15 -18
- package/build/lib/useBaseQuery.mjs.map +1 -1
- package/build/lib/useInfiniteQuery.d.ts +2 -4
- package/build/lib/useInfiniteQuery.esm.js +4 -4
- package/build/lib/useInfiniteQuery.esm.js.map +1 -1
- package/build/lib/useInfiniteQuery.js +3 -5
- package/build/lib/useInfiniteQuery.js.map +1 -1
- package/build/lib/useInfiniteQuery.mjs +4 -4
- package/build/lib/useInfiniteQuery.mjs.map +1 -1
- package/build/lib/useIsFetching.d.ts +2 -7
- package/build/lib/useIsFetching.esm.js +5 -9
- package/build/lib/useIsFetching.esm.js.map +1 -1
- package/build/lib/useIsFetching.js +7 -14
- package/build/lib/useIsFetching.js.map +1 -1
- package/build/lib/useIsFetching.mjs +5 -9
- package/build/lib/useIsFetching.mjs.map +1 -1
- package/build/lib/useMutation.d.ts +2 -5
- package/build/lib/useMutation.esm.js +12 -14
- package/build/lib/useMutation.esm.js.map +1 -1
- package/build/lib/useMutation.js +14 -19
- package/build/lib/useMutation.js.map +1 -1
- package/build/lib/useMutation.mjs +12 -14
- package/build/lib/useMutation.mjs.map +1 -1
- package/build/lib/useMutationState.d.ts +8 -0
- package/build/lib/useMutationState.esm.js +37 -0
- package/build/lib/useMutationState.esm.js.map +1 -0
- package/build/lib/useMutationState.js +59 -0
- package/build/lib/useMutationState.js.map +1 -0
- package/build/lib/useMutationState.mjs +37 -0
- package/build/lib/useMutationState.mjs.map +1 -0
- package/build/lib/useQueries.d.ts +9 -7
- package/build/lib/useQueries.esm.js +16 -27
- package/build/lib/useQueries.esm.js.map +1 -1
- package/build/lib/useQueries.js +19 -33
- package/build/lib/useQueries.js.map +1 -1
- package/build/lib/useQueries.mjs +16 -27
- package/build/lib/useQueries.mjs.map +1 -1
- package/build/lib/useQuery.d.ts +9 -21
- package/build/lib/useQuery.esm.js +5 -4
- package/build/lib/useQuery.esm.js.map +1 -1
- package/build/lib/useQuery.js +4 -5
- package/build/lib/useQuery.js.map +1 -1
- package/build/lib/useQuery.mjs +5 -4
- package/build/lib/useQuery.mjs.map +1 -1
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.esm.js +5 -6
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +5 -8
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +5 -6
- package/build/lib/utils.mjs.map +1 -1
- package/build/umd/index.development.js +1007 -1826
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +6 -18
- package/src/{Hydrate.tsx → HydrationBoundary.tsx} +17 -18
- package/src/QueryClientProvider.tsx +11 -65
- package/src/__tests__/{Hydrate.test.tsx → HydrationBoundary.test.tsx} +89 -77
- package/src/__tests__/QueryClientProvider.test.tsx +33 -147
- package/src/__tests__/QueryResetErrorBoundary.test.tsx +118 -85
- package/src/__tests__/ssr-hydration.test.tsx +27 -33
- package/src/__tests__/ssr.test.tsx +23 -9
- package/src/__tests__/suspense.test.tsx +194 -171
- package/src/__tests__/useInfiniteQuery.test.tsx +249 -494
- package/src/__tests__/useInfiniteQuery.type.test.tsx +131 -0
- package/src/__tests__/useIsFetching.test.tsx +65 -108
- package/src/__tests__/useMutation.test.tsx +200 -268
- package/src/__tests__/useMutationState.test.tsx +284 -0
- package/src/__tests__/useQueries.test.tsx +43 -347
- package/src/__tests__/useQuery.test.tsx +890 -686
- package/src/__tests__/useQuery.types.test.tsx +23 -24
- package/src/__tests__/utils.tsx +14 -23
- package/src/errorBoundaryUtils.ts +5 -10
- package/src/index.ts +4 -7
- package/src/types.ts +33 -38
- package/src/useBaseQuery.ts +7 -7
- package/src/useInfiniteQuery.ts +12 -77
- package/src/useIsFetching.ts +8 -20
- package/src/useMutation.ts +8 -66
- package/src/useMutationState.ts +81 -0
- package/src/useQueries.ts +29 -21
- package/src/useQuery.ts +27 -104
- package/src/utils.ts +5 -5
- package/build/lib/Hydrate.d.ts +0 -10
- package/build/lib/Hydrate.esm.js.map +0 -1
- package/build/lib/Hydrate.js.map +0 -1
- package/build/lib/Hydrate.mjs.map +0 -1
- package/build/lib/reactBatchedUpdates.d.ts +0 -2
- package/build/lib/reactBatchedUpdates.esm.js +0 -6
- package/build/lib/reactBatchedUpdates.esm.js.map +0 -1
- package/build/lib/reactBatchedUpdates.js +0 -30
- package/build/lib/reactBatchedUpdates.js.map +0 -1
- package/build/lib/reactBatchedUpdates.mjs +0 -6
- package/build/lib/reactBatchedUpdates.mjs.map +0 -1
- package/build/lib/reactBatchedUpdates.native.d.ts +0 -2
- package/build/lib/reactBatchedUpdates.native.esm.js +0 -2
- package/build/lib/reactBatchedUpdates.native.esm.js.map +0 -1
- package/build/lib/reactBatchedUpdates.native.js +0 -13
- package/build/lib/reactBatchedUpdates.native.js.map +0 -1
- package/build/lib/reactBatchedUpdates.native.mjs +0 -2
- package/build/lib/reactBatchedUpdates.native.mjs.map +0 -1
- package/build/lib/setBatchUpdatesFn.esm.js +0 -5
- package/build/lib/setBatchUpdatesFn.esm.js.map +0 -1
- package/build/lib/setBatchUpdatesFn.js +0 -7
- package/build/lib/setBatchUpdatesFn.js.map +0 -1
- package/build/lib/setBatchUpdatesFn.mjs +0 -5
- package/build/lib/setBatchUpdatesFn.mjs.map +0 -1
- package/build/lib/useIsMutating.d.ts +0 -7
- package/build/lib/useIsMutating.esm.js +0 -16
- package/build/lib/useIsMutating.esm.js.map +0 -1
- package/build/lib/useIsMutating.js +0 -40
- package/build/lib/useIsMutating.js.map +0 -1
- package/build/lib/useIsMutating.mjs +0 -16
- package/build/lib/useIsMutating.mjs.map +0 -1
- package/build/lib/useSyncExternalStore.d.ts +0 -2
- package/build/lib/useSyncExternalStore.esm.js +0 -7
- package/build/lib/useSyncExternalStore.esm.js.map +0 -1
- package/build/lib/useSyncExternalStore.js +0 -11
- package/build/lib/useSyncExternalStore.js.map +0 -1
- package/build/lib/useSyncExternalStore.mjs +0 -7
- package/build/lib/useSyncExternalStore.mjs.map +0 -1
- package/build/lib/useSyncExternalStore.native.d.ts +0 -2
- package/build/lib/useSyncExternalStore.native.esm.js +0 -2
- package/build/lib/useSyncExternalStore.native.esm.js.map +0 -1
- package/build/lib/useSyncExternalStore.native.js +0 -13
- package/build/lib/useSyncExternalStore.native.js.map +0 -1
- package/build/lib/useSyncExternalStore.native.mjs +0 -2
- package/build/lib/useSyncExternalStore.native.mjs.map +0 -1
- package/codemods/v4/key-transformation.js +0 -138
- package/codemods/v4/replace-import-specifier.js +0 -25
- package/codemods/v4/utils/index.js +0 -166
- package/codemods/v4/utils/replacers/key-replacer.js +0 -160
- package/codemods/v4/utils/transformers/query-cache-transformer.js +0 -115
- package/codemods/v4/utils/transformers/query-client-transformer.js +0 -49
- package/codemods/v4/utils/transformers/use-query-like-transformer.js +0 -32
- package/codemods/v4/utils/unprocessable-key-error.js +0 -8
- package/src/__tests__/useIsMutating.test.tsx +0 -259
- package/src/reactBatchedUpdates.native.ts +0 -4
- package/src/reactBatchedUpdates.ts +0 -2
- package/src/setBatchUpdatesFn.ts +0 -4
- package/src/useIsMutating.ts +0 -39
- package/src/useSyncExternalStore.native.ts +0 -5
- package/src/useSyncExternalStore.ts +0 -4
- /package/build/lib/__tests__/{Hydrate.test.d.ts → HydrationBoundary.test.d.ts} +0 -0
- /package/build/lib/__tests__/{useIsMutating.test.d.ts → useInfiniteQuery.type.test.d.ts} +0 -0
- /package/build/lib/{setBatchUpdatesFn.d.ts → __tests__/useMutationState.test.d.ts} +0 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { fireEvent, render, waitFor } from '@testing-library/react'
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import { useIsMutating, useMutationState } from '../useMutationState'
|
|
4
|
+
import { useMutation } from '../useMutation'
|
|
5
|
+
import {
|
|
6
|
+
createQueryClient,
|
|
7
|
+
renderWithClient,
|
|
8
|
+
setActTimeout,
|
|
9
|
+
sleep,
|
|
10
|
+
} from './utils'
|
|
11
|
+
import * as MutationCacheModule from '../../../query-core/src/mutationCache'
|
|
12
|
+
import { screen } from 'solid-testing-library'
|
|
13
|
+
|
|
14
|
+
describe('useIsMutating', () => {
|
|
15
|
+
it('should return the number of fetching mutations', async () => {
|
|
16
|
+
const isMutatings: number[] = []
|
|
17
|
+
const queryClient = createQueryClient()
|
|
18
|
+
|
|
19
|
+
function IsMutating() {
|
|
20
|
+
const isMutating = useIsMutating()
|
|
21
|
+
isMutatings.push(isMutating)
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function Mutations() {
|
|
26
|
+
const { mutate: mutate1 } = useMutation({
|
|
27
|
+
mutationKey: ['mutation1'],
|
|
28
|
+
mutationFn: async () => {
|
|
29
|
+
await sleep(150)
|
|
30
|
+
return 'data'
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
const { mutate: mutate2 } = useMutation({
|
|
34
|
+
mutationKey: ['mutation2'],
|
|
35
|
+
mutationFn: async () => {
|
|
36
|
+
await sleep(50)
|
|
37
|
+
return 'data'
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
mutate1()
|
|
43
|
+
setActTimeout(() => {
|
|
44
|
+
mutate2()
|
|
45
|
+
}, 50)
|
|
46
|
+
}, [mutate1, mutate2])
|
|
47
|
+
|
|
48
|
+
return null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function Page() {
|
|
52
|
+
return (
|
|
53
|
+
<div>
|
|
54
|
+
<IsMutating />
|
|
55
|
+
<Mutations />
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
renderWithClient(queryClient, <Page />)
|
|
61
|
+
await waitFor(() => expect(isMutatings).toEqual([0, 1, 2, 1, 0]))
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('should filter correctly by mutationKey', async () => {
|
|
65
|
+
const isMutatings: number[] = []
|
|
66
|
+
const queryClient = createQueryClient()
|
|
67
|
+
|
|
68
|
+
function IsMutating() {
|
|
69
|
+
const isMutating = useIsMutating({ mutationKey: ['mutation1'] })
|
|
70
|
+
isMutatings.push(isMutating)
|
|
71
|
+
return null
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function Page() {
|
|
75
|
+
const { mutate: mutate1 } = useMutation({
|
|
76
|
+
mutationKey: ['mutation1'],
|
|
77
|
+
mutationFn: async () => {
|
|
78
|
+
await sleep(100)
|
|
79
|
+
return 'data'
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
const { mutate: mutate2 } = useMutation({
|
|
83
|
+
mutationKey: ['mutation2'],
|
|
84
|
+
mutationFn: async () => {
|
|
85
|
+
await sleep(100)
|
|
86
|
+
return 'data'
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
React.useEffect(() => {
|
|
91
|
+
mutate1()
|
|
92
|
+
mutate2()
|
|
93
|
+
}, [mutate1, mutate2])
|
|
94
|
+
|
|
95
|
+
return <IsMutating />
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
renderWithClient(queryClient, <Page />)
|
|
99
|
+
await waitFor(() => expect(isMutatings).toEqual([0, 1, 0]))
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('should filter correctly by predicate', async () => {
|
|
103
|
+
const isMutatings: number[] = []
|
|
104
|
+
const queryClient = createQueryClient()
|
|
105
|
+
|
|
106
|
+
function IsMutating() {
|
|
107
|
+
const isMutating = useIsMutating({
|
|
108
|
+
predicate: (mutation) =>
|
|
109
|
+
mutation.options.mutationKey?.[0] === 'mutation1',
|
|
110
|
+
})
|
|
111
|
+
isMutatings.push(isMutating)
|
|
112
|
+
return null
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function Page() {
|
|
116
|
+
const { mutate: mutate1 } = useMutation({
|
|
117
|
+
mutationKey: ['mutation1'],
|
|
118
|
+
mutationFn: async () => {
|
|
119
|
+
await sleep(100)
|
|
120
|
+
return 'data'
|
|
121
|
+
},
|
|
122
|
+
})
|
|
123
|
+
const { mutate: mutate2 } = useMutation({
|
|
124
|
+
mutationKey: ['mutation2'],
|
|
125
|
+
mutationFn: async () => {
|
|
126
|
+
await sleep(100)
|
|
127
|
+
return 'data'
|
|
128
|
+
},
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
React.useEffect(() => {
|
|
132
|
+
mutate1()
|
|
133
|
+
mutate2()
|
|
134
|
+
}, [mutate1, mutate2])
|
|
135
|
+
|
|
136
|
+
return <IsMutating />
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
renderWithClient(queryClient, <Page />)
|
|
140
|
+
await waitFor(() => expect(isMutatings).toEqual([0, 1, 0]))
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('should not change state if unmounted', async () => {
|
|
144
|
+
// We have to mock the MutationCache to not unsubscribe
|
|
145
|
+
// the listener when the component is unmounted
|
|
146
|
+
class MutationCacheMock extends MutationCacheModule.MutationCache {
|
|
147
|
+
subscribe(listener: any) {
|
|
148
|
+
super.subscribe(listener)
|
|
149
|
+
return () => void 0
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const MutationCacheSpy = jest
|
|
154
|
+
.spyOn(MutationCacheModule, 'MutationCache')
|
|
155
|
+
.mockImplementation((fn) => {
|
|
156
|
+
return new MutationCacheMock(fn)
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
const queryClient = createQueryClient()
|
|
160
|
+
|
|
161
|
+
function IsMutating() {
|
|
162
|
+
useIsMutating()
|
|
163
|
+
return null
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function Page() {
|
|
167
|
+
const [mounted, setMounted] = React.useState(true)
|
|
168
|
+
const { mutate: mutate1 } = useMutation({
|
|
169
|
+
mutationKey: ['mutation1'],
|
|
170
|
+
mutationFn: async () => {
|
|
171
|
+
await sleep(10)
|
|
172
|
+
return 'data'
|
|
173
|
+
},
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
React.useEffect(() => {
|
|
177
|
+
mutate1()
|
|
178
|
+
}, [mutate1])
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<div>
|
|
182
|
+
<button onClick={() => setMounted(false)}>unmount</button>
|
|
183
|
+
{mounted && <IsMutating />}
|
|
184
|
+
</div>
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const { getByText } = renderWithClient(queryClient, <Page />)
|
|
189
|
+
fireEvent.click(getByText('unmount'))
|
|
190
|
+
|
|
191
|
+
// Should not display the console error
|
|
192
|
+
// "Warning: Can't perform a React state update on an unmounted component"
|
|
193
|
+
|
|
194
|
+
await sleep(20)
|
|
195
|
+
MutationCacheSpy.mockRestore()
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
it('should use provided custom queryClient', async () => {
|
|
199
|
+
const queryClient = createQueryClient()
|
|
200
|
+
|
|
201
|
+
function Page() {
|
|
202
|
+
const isMutating = useIsMutating({}, queryClient)
|
|
203
|
+
const { mutate } = useMutation(
|
|
204
|
+
{
|
|
205
|
+
mutationKey: ['mutation1'],
|
|
206
|
+
mutationFn: async () => {
|
|
207
|
+
await sleep(10)
|
|
208
|
+
return 'data'
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
queryClient,
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
React.useEffect(() => {
|
|
215
|
+
mutate()
|
|
216
|
+
}, [mutate])
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<div>
|
|
220
|
+
<div>mutating: {isMutating}</div>
|
|
221
|
+
</div>
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const rendered = render(<Page></Page>)
|
|
226
|
+
|
|
227
|
+
await waitFor(() => rendered.getByText('mutating: 1'))
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
describe('useMutationState', () => {
|
|
232
|
+
it('should return variables after calling mutate', async () => {
|
|
233
|
+
const queryClient = createQueryClient()
|
|
234
|
+
const variables: unknown[][] = []
|
|
235
|
+
const mutationKey = ['mutation']
|
|
236
|
+
|
|
237
|
+
function Variables() {
|
|
238
|
+
variables.push(
|
|
239
|
+
useMutationState({
|
|
240
|
+
filters: { mutationKey, status: 'pending' },
|
|
241
|
+
select: (mutation) => mutation.state.variables,
|
|
242
|
+
}),
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
return null
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function Mutate() {
|
|
249
|
+
const { mutate, data } = useMutation({
|
|
250
|
+
mutationKey,
|
|
251
|
+
mutationFn: async (input: number) => {
|
|
252
|
+
await sleep(150)
|
|
253
|
+
return 'data' + input
|
|
254
|
+
},
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
return (
|
|
258
|
+
<div>
|
|
259
|
+
data: {data ?? 'null'}
|
|
260
|
+
<button onClick={() => mutate(1)}>mutate</button>
|
|
261
|
+
</div>
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function Page() {
|
|
266
|
+
return (
|
|
267
|
+
<div>
|
|
268
|
+
<Variables />
|
|
269
|
+
<Mutate />
|
|
270
|
+
</div>
|
|
271
|
+
)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const rendered = renderWithClient(queryClient, <Page />)
|
|
275
|
+
|
|
276
|
+
await waitFor(() => rendered.getByText('data: null'))
|
|
277
|
+
|
|
278
|
+
fireEvent.click(screen.getByRole('button', { name: /mutate/i }))
|
|
279
|
+
|
|
280
|
+
await waitFor(() => rendered.getByText('data: data1'))
|
|
281
|
+
|
|
282
|
+
expect(variables).toEqual([[], [1], []])
|
|
283
|
+
})
|
|
284
|
+
})
|