@tanstack/query-core 4.0.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/cjs/focusManager.js +101 -0
- package/build/cjs/focusManager.js.map +1 -0
- package/build/cjs/hydration.js +112 -0
- package/build/cjs/hydration.js.map +1 -0
- package/build/cjs/index.js +51 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/infiniteQueryBehavior.js +160 -0
- package/build/cjs/infiniteQueryBehavior.js.map +1 -0
- package/build/cjs/infiniteQueryObserver.js +92 -0
- package/build/cjs/infiniteQueryObserver.js.map +1 -0
- package/build/cjs/logger.js +18 -0
- package/build/cjs/logger.js.map +1 -0
- package/build/cjs/mutation.js +258 -0
- package/build/cjs/mutation.js.map +1 -0
- package/build/cjs/mutationCache.js +99 -0
- package/build/cjs/mutationCache.js.map +1 -0
- package/build/cjs/mutationObserver.js +130 -0
- package/build/cjs/mutationObserver.js.map +1 -0
- package/build/cjs/notifyManager.js +114 -0
- package/build/cjs/notifyManager.js.map +1 -0
- package/build/cjs/onlineManager.js +100 -0
- package/build/cjs/onlineManager.js.map +1 -0
- package/build/cjs/queriesObserver.js +170 -0
- package/build/cjs/queriesObserver.js.map +1 -0
- package/build/cjs/query.js +474 -0
- package/build/cjs/query.js.map +1 -0
- package/build/cjs/queryCache.js +140 -0
- package/build/cjs/queryCache.js.map +1 -0
- package/build/cjs/queryClient.js +357 -0
- package/build/cjs/queryClient.js.map +1 -0
- package/build/cjs/queryObserver.js +521 -0
- package/build/cjs/queryObserver.js.map +1 -0
- package/build/cjs/removable.js +47 -0
- package/build/cjs/removable.js.map +1 -0
- package/build/cjs/retryer.js +177 -0
- package/build/cjs/retryer.js.map +1 -0
- package/build/cjs/subscribable.js +43 -0
- package/build/cjs/subscribable.js.map +1 -0
- package/build/cjs/utils.js +356 -0
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +3077 -0
- package/build/esm/index.js.map +1 -0
- package/build/stats-html.html +2689 -0
- package/build/umd/index.development.js +3106 -0
- package/build/umd/index.development.js.map +1 -0
- package/build/umd/index.production.js +12 -0
- package/build/umd/index.production.js.map +1 -0
- package/package.json +25 -0
- package/src/focusManager.ts +89 -0
- package/src/hydration.ts +164 -0
- package/src/index.ts +35 -0
- package/src/infiniteQueryBehavior.ts +214 -0
- package/src/infiniteQueryObserver.ts +159 -0
- package/src/logger.native.ts +11 -0
- package/src/logger.ts +9 -0
- package/src/mutation.ts +349 -0
- package/src/mutationCache.ts +157 -0
- package/src/mutationObserver.ts +195 -0
- package/src/notifyManager.ts +96 -0
- package/src/onlineManager.ts +89 -0
- package/src/queriesObserver.ts +211 -0
- package/src/query.ts +612 -0
- package/src/queryCache.ts +206 -0
- package/src/queryClient.ts +716 -0
- package/src/queryObserver.ts +748 -0
- package/src/removable.ts +37 -0
- package/src/retryer.ts +215 -0
- package/src/subscribable.ts +33 -0
- package/src/tests/focusManager.test.tsx +155 -0
- package/src/tests/hydration.test.tsx +429 -0
- package/src/tests/infiniteQueryBehavior.test.tsx +124 -0
- package/src/tests/infiniteQueryObserver.test.tsx +64 -0
- package/src/tests/mutationCache.test.tsx +260 -0
- package/src/tests/mutationObserver.test.tsx +75 -0
- package/src/tests/mutations.test.tsx +363 -0
- package/src/tests/notifyManager.test.tsx +51 -0
- package/src/tests/onlineManager.test.tsx +148 -0
- package/src/tests/queriesObserver.test.tsx +330 -0
- package/src/tests/query.test.tsx +888 -0
- package/src/tests/queryCache.test.tsx +236 -0
- package/src/tests/queryClient.test.tsx +1435 -0
- package/src/tests/queryObserver.test.tsx +802 -0
- package/src/tests/utils.test.tsx +360 -0
- package/src/types.ts +705 -0
- package/src/utils.ts +435 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import {
|
|
2
|
+
replaceEqualDeep,
|
|
3
|
+
partialDeepEqual,
|
|
4
|
+
isPlainObject,
|
|
5
|
+
parseMutationArgs,
|
|
6
|
+
matchMutation,
|
|
7
|
+
scheduleMicrotask,
|
|
8
|
+
sleep,
|
|
9
|
+
isPlainArray,
|
|
10
|
+
} from '../utils'
|
|
11
|
+
import { Mutation } from '../mutation'
|
|
12
|
+
import { createQueryClient } from '../../../../tests/utils'
|
|
13
|
+
|
|
14
|
+
describe('core/utils', () => {
|
|
15
|
+
describe('isPlainObject', () => {
|
|
16
|
+
it('should return `true` for a plain object', () => {
|
|
17
|
+
expect(isPlainObject({})).toEqual(true)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('should return `false` for an array', () => {
|
|
21
|
+
expect(isPlainObject([])).toEqual(false)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('should return `false` for null', () => {
|
|
25
|
+
expect(isPlainObject(null)).toEqual(false)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('should return `false` for undefined', () => {
|
|
29
|
+
expect(isPlainObject(undefined)).toEqual(false)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('should return `true` for object with an undefined constructor', () => {
|
|
33
|
+
expect(isPlainObject(Object.create(null))).toBeTruthy()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('should return `false` if constructor does not have an Object-specific method', () => {
|
|
37
|
+
class Foo {
|
|
38
|
+
abc: any
|
|
39
|
+
constructor() {
|
|
40
|
+
this.abc = {}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
expect(isPlainObject(new Foo())).toBeFalsy()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('should return `false` if the object has a modified prototype', () => {
|
|
47
|
+
function Graph(this: any) {
|
|
48
|
+
this.vertices = []
|
|
49
|
+
this.edges = []
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
Graph.prototype.addVertex = function (v: any) {
|
|
53
|
+
this.vertices.push(v)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
expect(isPlainObject(Object.create(Graph))).toBeFalsy()
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
describe('isPlainArray', () => {
|
|
61
|
+
it('should return `true` for plain arrays', () => {
|
|
62
|
+
expect(isPlainArray([1, 2])).toEqual(true)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('should return `false` for non plain arrays', () => {
|
|
66
|
+
expect(isPlainArray(Object.assign([1, 2], { a: 'b' }))).toEqual(false)
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
describe('partialDeepEqual', () => {
|
|
71
|
+
it('should return `true` if a includes b', () => {
|
|
72
|
+
const a = { a: { b: 'b' }, c: 'c', d: [{ d: 'd ' }] }
|
|
73
|
+
const b = { a: { b: 'b' }, c: 'c', d: [] }
|
|
74
|
+
expect(partialDeepEqual(a, b)).toEqual(true)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('should return `false` if a does not include b', () => {
|
|
78
|
+
const a = { a: { b: 'b' }, c: 'c', d: [] }
|
|
79
|
+
const b = { a: { b: 'b' }, c: 'c', d: [{ d: 'd ' }] }
|
|
80
|
+
expect(partialDeepEqual(a, b)).toEqual(false)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('should return `true` if array a includes array b', () => {
|
|
84
|
+
const a = [1, 2, 3]
|
|
85
|
+
const b = [1, 2]
|
|
86
|
+
expect(partialDeepEqual(a, b)).toEqual(true)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('should return `false` if a is null and b is not', () => {
|
|
90
|
+
const a = null
|
|
91
|
+
const b = { a: { b: 'b' }, c: 'c', d: [{ d: 'd ' }] }
|
|
92
|
+
expect(partialDeepEqual(a, b)).toEqual(false)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('should return `false` if a contains null and b is not', () => {
|
|
96
|
+
const a = { a: null, c: 'c', d: [] }
|
|
97
|
+
const b = { a: { b: 'b' }, c: 'c', d: [{ d: 'd ' }] }
|
|
98
|
+
expect(partialDeepEqual(a, b)).toEqual(false)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('should return `false` if b is null and a is not', () => {
|
|
102
|
+
const a = { a: { b: 'b' }, c: 'c', d: [] }
|
|
103
|
+
const b = null
|
|
104
|
+
expect(partialDeepEqual(a, b)).toEqual(false)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('should return `false` if b contains null and a is not', () => {
|
|
108
|
+
const a = { a: { b: 'b' }, c: 'c', d: [] }
|
|
109
|
+
const b = { a: null, c: 'c', d: [{ d: 'd ' }] }
|
|
110
|
+
expect(partialDeepEqual(a, b)).toEqual(false)
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
describe('replaceEqualDeep', () => {
|
|
115
|
+
it('should return the previous value when the next value is an equal primitive', () => {
|
|
116
|
+
expect(replaceEqualDeep(1, 1)).toBe(1)
|
|
117
|
+
expect(replaceEqualDeep('1', '1')).toBe('1')
|
|
118
|
+
expect(replaceEqualDeep(true, true)).toBe(true)
|
|
119
|
+
expect(replaceEqualDeep(false, false)).toBe(false)
|
|
120
|
+
expect(replaceEqualDeep(null, null)).toBe(null)
|
|
121
|
+
expect(replaceEqualDeep(undefined, undefined)).toBe(undefined)
|
|
122
|
+
})
|
|
123
|
+
it('should return the next value when the previous value is a different value', () => {
|
|
124
|
+
const date1 = new Date()
|
|
125
|
+
const date2 = new Date()
|
|
126
|
+
expect(replaceEqualDeep(1, 0)).toBe(0)
|
|
127
|
+
expect(replaceEqualDeep(1, 2)).toBe(2)
|
|
128
|
+
expect(replaceEqualDeep('1', '2')).toBe('2')
|
|
129
|
+
expect(replaceEqualDeep(true, false)).toBe(false)
|
|
130
|
+
expect(replaceEqualDeep(false, true)).toBe(true)
|
|
131
|
+
expect(replaceEqualDeep(date1, date2)).toBe(date2)
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('should return the next value when the previous value is a different type', () => {
|
|
135
|
+
const array = [1]
|
|
136
|
+
const object = { a: 'a' }
|
|
137
|
+
expect(replaceEqualDeep(0, undefined)).toBe(undefined)
|
|
138
|
+
expect(replaceEqualDeep(undefined, 0)).toBe(0)
|
|
139
|
+
expect(replaceEqualDeep(2, undefined)).toBe(undefined)
|
|
140
|
+
expect(replaceEqualDeep(undefined, 2)).toBe(2)
|
|
141
|
+
expect(replaceEqualDeep(undefined, null)).toBe(null)
|
|
142
|
+
expect(replaceEqualDeep(null, undefined)).toBe(undefined)
|
|
143
|
+
expect(replaceEqualDeep({}, undefined)).toBe(undefined)
|
|
144
|
+
expect(replaceEqualDeep([], undefined)).toBe(undefined)
|
|
145
|
+
expect(replaceEqualDeep(array, object)).toBe(object)
|
|
146
|
+
expect(replaceEqualDeep(object, array)).toBe(array)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('should return the previous value when the next value is an equal array', () => {
|
|
150
|
+
const prev = [1, 2]
|
|
151
|
+
const next = [1, 2]
|
|
152
|
+
expect(replaceEqualDeep(prev, next)).toBe(prev)
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
it('should return a copy when the previous value is a different array subset', () => {
|
|
156
|
+
const prev = [1, 2]
|
|
157
|
+
const next = [1, 2, 3]
|
|
158
|
+
const result = replaceEqualDeep(prev, next)
|
|
159
|
+
expect(result).toEqual(next)
|
|
160
|
+
expect(result).not.toBe(prev)
|
|
161
|
+
expect(result).not.toBe(next)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('should return a copy when the previous value is a different array superset', () => {
|
|
165
|
+
const prev = [1, 2, 3]
|
|
166
|
+
const next = [1, 2]
|
|
167
|
+
const result = replaceEqualDeep(prev, next)
|
|
168
|
+
expect(result).toEqual(next)
|
|
169
|
+
expect(result).not.toBe(prev)
|
|
170
|
+
expect(result).not.toBe(next)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
it('should return the previous value when the next value is an equal empty array', () => {
|
|
174
|
+
const prev: any[] = []
|
|
175
|
+
const next: any[] = []
|
|
176
|
+
expect(replaceEqualDeep(prev, next)).toBe(prev)
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('should return the previous value when the next value is an equal empty object', () => {
|
|
180
|
+
const prev = {}
|
|
181
|
+
const next = {}
|
|
182
|
+
expect(replaceEqualDeep(prev, next)).toBe(prev)
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
it('should return the previous value when the next value is an equal object', () => {
|
|
186
|
+
const prev = { a: 'a' }
|
|
187
|
+
const next = { a: 'a' }
|
|
188
|
+
expect(replaceEqualDeep(prev, next)).toBe(prev)
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
it('should replace different values in objects', () => {
|
|
192
|
+
const prev = { a: { b: 'b' }, c: 'c' }
|
|
193
|
+
const next = { a: { b: 'b' }, c: 'd' }
|
|
194
|
+
const result = replaceEqualDeep(prev, next)
|
|
195
|
+
expect(result).toEqual(next)
|
|
196
|
+
expect(result).not.toBe(prev)
|
|
197
|
+
expect(result).not.toBe(next)
|
|
198
|
+
expect(result.a).toBe(prev.a)
|
|
199
|
+
expect(result.c).toBe(next.c)
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
it('should replace different values in arrays', () => {
|
|
203
|
+
const prev = [1, { a: 'a' }, { b: { b: 'b' } }, [1]] as const
|
|
204
|
+
const next = [1, { a: 'a' }, { b: { b: 'c' } }, [1]] as const
|
|
205
|
+
const result = replaceEqualDeep(prev, next)
|
|
206
|
+
expect(result).toEqual(next)
|
|
207
|
+
expect(result).not.toBe(prev)
|
|
208
|
+
expect(result).not.toBe(next)
|
|
209
|
+
expect(result[0]).toBe(prev[0])
|
|
210
|
+
expect(result[1]).toBe(prev[1])
|
|
211
|
+
expect(result[2]).not.toBe(next[2])
|
|
212
|
+
expect(result[2].b.b).toBe(next[2].b.b)
|
|
213
|
+
expect(result[3]).toBe(prev[3])
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
it('should replace different values in arrays when the next value is a subset', () => {
|
|
217
|
+
const prev = [{ a: 'a' }, { b: 'b' }, { c: 'c' }]
|
|
218
|
+
const next = [{ a: 'a' }, { b: 'b' }]
|
|
219
|
+
const result = replaceEqualDeep(prev, next)
|
|
220
|
+
expect(result).toEqual(next)
|
|
221
|
+
expect(result).not.toBe(prev)
|
|
222
|
+
expect(result).not.toBe(next)
|
|
223
|
+
expect(result[0]).toBe(prev[0])
|
|
224
|
+
expect(result[1]).toBe(prev[1])
|
|
225
|
+
expect(result[2]).toBeUndefined()
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
it('should replace different values in arrays when the next value is a superset', () => {
|
|
229
|
+
const prev = [{ a: 'a' }, { b: 'b' }]
|
|
230
|
+
const next = [{ a: 'a' }, { b: 'b' }, { c: 'c' }]
|
|
231
|
+
const result = replaceEqualDeep(prev, next)
|
|
232
|
+
expect(result).toEqual(next)
|
|
233
|
+
expect(result).not.toBe(prev)
|
|
234
|
+
expect(result).not.toBe(next)
|
|
235
|
+
expect(result[0]).toBe(prev[0])
|
|
236
|
+
expect(result[1]).toBe(prev[1])
|
|
237
|
+
expect(result[2]).toBe(next[2])
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
it('should copy objects which are not arrays or objects', () => {
|
|
241
|
+
const prev = [{ a: 'a' }, { b: 'b' }, { c: 'c' }, 1]
|
|
242
|
+
const next = [{ a: 'a' }, new Map(), { c: 'c' }, 2]
|
|
243
|
+
const result = replaceEqualDeep(prev, next)
|
|
244
|
+
expect(result).not.toBe(prev)
|
|
245
|
+
expect(result).not.toBe(next)
|
|
246
|
+
expect(result[0]).toBe(prev[0])
|
|
247
|
+
expect(result[1]).toBe(next[1])
|
|
248
|
+
expect(result[2]).toBe(prev[2])
|
|
249
|
+
expect(result[3]).toBe(next[3])
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
it('should support equal objects which are not arrays or objects', () => {
|
|
253
|
+
const map = new Map()
|
|
254
|
+
const prev = [map, [1]]
|
|
255
|
+
const next = [map, [1]]
|
|
256
|
+
const result = replaceEqualDeep(prev, next)
|
|
257
|
+
expect(result).toBe(prev)
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
it('should support non equal objects which are not arrays or objects', () => {
|
|
261
|
+
const map1 = new Map()
|
|
262
|
+
const map2 = new Map()
|
|
263
|
+
const prev = [map1, [1]]
|
|
264
|
+
const next = [map2, [1]]
|
|
265
|
+
const result = replaceEqualDeep(prev, next)
|
|
266
|
+
expect(result).not.toBe(prev)
|
|
267
|
+
expect(result).not.toBe(next)
|
|
268
|
+
expect(result[0]).toBe(next[0])
|
|
269
|
+
expect(result[1]).toBe(prev[1])
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
it('should support objects which are not plain arrays', () => {
|
|
273
|
+
const prev = Object.assign([1, 2], { a: { b: 'b' }, c: 'c' })
|
|
274
|
+
const next = Object.assign([1, 2], { a: { b: 'b' }, c: 'c' })
|
|
275
|
+
const result = replaceEqualDeep(prev, next)
|
|
276
|
+
expect(result).toBe(next)
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
it('should replace all parent objects if some nested value changes', () => {
|
|
280
|
+
const prev = {
|
|
281
|
+
todo: { id: '1', meta: { createdAt: 0 }, state: { done: false } },
|
|
282
|
+
otherTodo: { id: '2', meta: { createdAt: 0 }, state: { done: true } },
|
|
283
|
+
}
|
|
284
|
+
const next = {
|
|
285
|
+
todo: { id: '1', meta: { createdAt: 0 }, state: { done: true } },
|
|
286
|
+
otherTodo: { id: '2', meta: { createdAt: 0 }, state: { done: true } },
|
|
287
|
+
}
|
|
288
|
+
const result = replaceEqualDeep(prev, next)
|
|
289
|
+
expect(result).toEqual(next)
|
|
290
|
+
expect(result).not.toBe(prev)
|
|
291
|
+
expect(result).not.toBe(next)
|
|
292
|
+
expect(result.todo).not.toBe(prev.todo)
|
|
293
|
+
expect(result.todo).not.toBe(next.todo)
|
|
294
|
+
expect(result.todo.id).toBe(next.todo.id)
|
|
295
|
+
expect(result.todo.meta).toBe(prev.todo.meta)
|
|
296
|
+
expect(result.todo.state).not.toBe(next.todo.state)
|
|
297
|
+
expect(result.todo.state.done).toBe(next.todo.state.done)
|
|
298
|
+
expect(result.otherTodo).toBe(prev.otherTodo)
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
it('should replace all parent arrays if some nested value changes', () => {
|
|
302
|
+
const prev = {
|
|
303
|
+
todos: [
|
|
304
|
+
{ id: '1', meta: { createdAt: 0 }, state: { done: false } },
|
|
305
|
+
{ id: '2', meta: { createdAt: 0 }, state: { done: true } },
|
|
306
|
+
],
|
|
307
|
+
}
|
|
308
|
+
const next = {
|
|
309
|
+
todos: [
|
|
310
|
+
{ id: '1', meta: { createdAt: 0 }, state: { done: true } },
|
|
311
|
+
{ id: '2', meta: { createdAt: 0 }, state: { done: true } },
|
|
312
|
+
],
|
|
313
|
+
}
|
|
314
|
+
const result = replaceEqualDeep(prev, next)
|
|
315
|
+
expect(result).toEqual(next)
|
|
316
|
+
expect(result).not.toBe(prev)
|
|
317
|
+
expect(result).not.toBe(next)
|
|
318
|
+
expect(result.todos).not.toBe(prev.todos)
|
|
319
|
+
expect(result.todos).not.toBe(next.todos)
|
|
320
|
+
expect(result.todos[0]).not.toBe(prev.todos[0])
|
|
321
|
+
expect(result.todos[0]).not.toBe(next.todos[0])
|
|
322
|
+
expect(result.todos[0]?.id).toBe(next.todos[0]?.id)
|
|
323
|
+
expect(result.todos[0]?.meta).toBe(prev.todos[0]?.meta)
|
|
324
|
+
expect(result.todos[0]?.state).not.toBe(next.todos[0]?.state)
|
|
325
|
+
expect(result.todos[0]?.state.done).toBe(next.todos[0]?.state.done)
|
|
326
|
+
expect(result.todos[1]).toBe(prev.todos[1])
|
|
327
|
+
})
|
|
328
|
+
})
|
|
329
|
+
|
|
330
|
+
describe('parseMutationArgs', () => {
|
|
331
|
+
it('should return mutation options', () => {
|
|
332
|
+
const options = { mutationKey: ['key'] }
|
|
333
|
+
expect(parseMutationArgs(options)).toMatchObject(options)
|
|
334
|
+
})
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
describe('matchMutation', () => {
|
|
338
|
+
it('should return false if mutationKey options is undefined', () => {
|
|
339
|
+
const filters = { mutationKey: ['key1'] }
|
|
340
|
+
const queryClient = createQueryClient()
|
|
341
|
+
const mutation = new Mutation({
|
|
342
|
+
mutationId: 1,
|
|
343
|
+
mutationCache: queryClient.getMutationCache(),
|
|
344
|
+
options: {},
|
|
345
|
+
})
|
|
346
|
+
expect(matchMutation(filters, mutation)).toBeFalsy()
|
|
347
|
+
})
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
describe('scheduleMicrotask', () => {
|
|
351
|
+
it('should defer execution of callback', async () => {
|
|
352
|
+
const callback = jest.fn()
|
|
353
|
+
|
|
354
|
+
scheduleMicrotask(callback)
|
|
355
|
+
expect(callback).not.toHaveBeenCalled()
|
|
356
|
+
await sleep(0)
|
|
357
|
+
expect(callback).toHaveBeenCalledTimes(1)
|
|
358
|
+
})
|
|
359
|
+
})
|
|
360
|
+
})
|