@tanstack/query-core 4.7.1 → 4.7.2
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/LICENSE +21 -0
- package/package.json +2 -2
- package/src/tests/query.test.tsx +11 -30
- package/src/tests/queryClient.test.tsx +2 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Tanner Linsley
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/query-core",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.2",
|
|
4
4
|
"description": "TODO",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,4 +31,4 @@
|
|
|
31
31
|
"clean": "rm -rf ./build",
|
|
32
32
|
"test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src"
|
|
33
33
|
}
|
|
34
|
-
}
|
|
34
|
+
}
|
package/src/tests/query.test.tsx
CHANGED
|
@@ -201,11 +201,7 @@ describe('query', () => {
|
|
|
201
201
|
expect(args).toBeDefined()
|
|
202
202
|
expect(args.pageParam).toBeUndefined()
|
|
203
203
|
expect(args.queryKey).toEqual(key)
|
|
204
|
-
|
|
205
|
-
expect(args.signal).toBeInstanceOf(AbortSignal)
|
|
206
|
-
} else {
|
|
207
|
-
expect(args.signal).toBeUndefined()
|
|
208
|
-
}
|
|
204
|
+
expect(args.signal).toBeInstanceOf(AbortSignal)
|
|
209
205
|
})
|
|
210
206
|
|
|
211
207
|
test('should continue if cancellation is not supported and signal is not consumed', async () => {
|
|
@@ -259,20 +255,11 @@ describe('query', () => {
|
|
|
259
255
|
|
|
260
256
|
const query = queryCache.find(key)!
|
|
261
257
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
})
|
|
268
|
-
} else {
|
|
269
|
-
expect(query.state).toMatchObject({
|
|
270
|
-
data: 'data',
|
|
271
|
-
status: 'success',
|
|
272
|
-
fetchStatus: 'idle',
|
|
273
|
-
dataUpdateCount: 1,
|
|
274
|
-
})
|
|
275
|
-
}
|
|
258
|
+
expect(query.state).toMatchObject({
|
|
259
|
+
data: undefined,
|
|
260
|
+
status: 'loading',
|
|
261
|
+
fetchStatus: 'idle',
|
|
262
|
+
})
|
|
276
263
|
})
|
|
277
264
|
|
|
278
265
|
test('should provide an AbortSignal to the queryFn that provides info about the cancellation state', async () => {
|
|
@@ -312,12 +299,8 @@ describe('query', () => {
|
|
|
312
299
|
|
|
313
300
|
expect(queryFn).toHaveBeenCalledTimes(1)
|
|
314
301
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (typeof AbortSignal === 'function') {
|
|
318
|
-
signal = queryFn.mock.calls[0]![0].signal
|
|
319
|
-
expect(signal?.aborted).toBe(false)
|
|
320
|
-
}
|
|
302
|
+
const signal = queryFn.mock.calls[0]![0].signal
|
|
303
|
+
expect(signal?.aborted).toBe(false)
|
|
321
304
|
expect(onAbort).not.toHaveBeenCalled()
|
|
322
305
|
expect(abortListener).not.toHaveBeenCalled()
|
|
323
306
|
|
|
@@ -325,11 +308,9 @@ describe('query', () => {
|
|
|
325
308
|
|
|
326
309
|
await sleep(100)
|
|
327
310
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
expect(abortListener).toHaveBeenCalledTimes(1)
|
|
332
|
-
}
|
|
311
|
+
expect(signal?.aborted).toBe(true)
|
|
312
|
+
expect(onAbort).toHaveBeenCalledTimes(1)
|
|
313
|
+
expect(abortListener).toHaveBeenCalledTimes(1)
|
|
333
314
|
expect(isCancelledError(error)).toBe(true)
|
|
334
315
|
})
|
|
335
316
|
|
|
@@ -1176,9 +1176,7 @@ describe('queryClient', () => {
|
|
|
1176
1176
|
|
|
1177
1177
|
await queryClient.refetchQueries()
|
|
1178
1178
|
observer.destroy()
|
|
1179
|
-
|
|
1180
|
-
expect(abortFn).toHaveBeenCalledTimes(1)
|
|
1181
|
-
}
|
|
1179
|
+
expect(abortFn).toHaveBeenCalledTimes(1)
|
|
1182
1180
|
expect(fetchCount).toBe(2)
|
|
1183
1181
|
})
|
|
1184
1182
|
|
|
@@ -1203,9 +1201,7 @@ describe('queryClient', () => {
|
|
|
1203
1201
|
|
|
1204
1202
|
await queryClient.refetchQueries(undefined, { cancelRefetch: false })
|
|
1205
1203
|
observer.destroy()
|
|
1206
|
-
|
|
1207
|
-
expect(abortFn).toHaveBeenCalledTimes(0)
|
|
1208
|
-
}
|
|
1204
|
+
expect(abortFn).toHaveBeenCalledTimes(0)
|
|
1209
1205
|
expect(fetchCount).toBe(1)
|
|
1210
1206
|
})
|
|
1211
1207
|
})
|