Skip to content

Commit 4d8bbbf

Browse files
sukvvonmanudeli
andauthored
test(query-core/queryCache): remove redundant 'advanceTimersByTimeAsync' (#9433)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
1 parent b4a847e commit 4d8bbbf

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

packages/query-core/src/__tests__/queryCache.test.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ describe('queryCache', () => {
1818
})
1919

2020
describe('subscribe', () => {
21-
test('should pass the correct query', async () => {
21+
test('should pass the correct query', () => {
2222
const key = queryKey()
2323
const subscriber = vi.fn()
2424
const unsubscribe = queryCache.subscribe(subscriber)
2525
queryClient.setQueryData(key, 'foo')
2626
const query = queryCache.find({ queryKey: key })
27-
await vi.advanceTimersByTimeAsync(0)
2827
expect(subscriber).toHaveBeenCalledWith({ query, type: 'added' })
2928
unsubscribe()
3029
})
@@ -88,8 +87,8 @@ describe('queryCache', () => {
8887
queryKey: key,
8988
queryFn: () => sleep(100).then(() => 'data'),
9089
})
91-
const query = queryCache.find({ queryKey: key })
9290
await vi.advanceTimersByTimeAsync(100)
91+
const query = queryCache.find({ queryKey: key })
9392
expect(callback).toHaveBeenCalledWith({ query, type: 'added' })
9493
})
9594

@@ -130,13 +129,11 @@ describe('queryCache', () => {
130129
queryKey: ['key1'],
131130
queryFn: () => sleep(100).then(() => 'data1'),
132131
})
133-
await vi.advanceTimersByTimeAsync(100)
134132
expect(testCache.findAll().length).toBe(1)
135133
testClient.prefetchQuery({
136134
queryKey: ['key2'],
137135
queryFn: () => sleep(100).then(() => 'data2'),
138136
})
139-
await vi.advanceTimersByTimeAsync(100)
140137
expect(testCache.findAll().length).toBe(2)
141138
testClient.prefetchQuery({
142139
queryKey: ['key3'],
@@ -183,17 +180,14 @@ describe('queryCache', () => {
183180
queryKey: key1,
184181
queryFn: () => sleep(100).then(() => 'data1'),
185182
})
186-
await vi.advanceTimersByTimeAsync(100)
187183
queryClient.prefetchQuery({
188184
queryKey: key2,
189185
queryFn: () => sleep(100).then(() => 'data2'),
190186
})
191-
await vi.advanceTimersByTimeAsync(100)
192187
queryClient.prefetchQuery({
193188
queryKey: [{ a: 'a', b: 'b' }],
194189
queryFn: () => sleep(100).then(() => 'data3'),
195190
})
196-
await vi.advanceTimersByTimeAsync(100)
197191
queryClient.prefetchQuery({
198192
queryKey: ['posts', 1],
199193
queryFn: () => sleep(100).then(() => 'data4'),

0 commit comments

Comments
 (0)