Skip to content

Commit 4b70794

Browse files
dngur9801TkDodo
authored andcommitted
test: remove unnecessary async keywords (#8784)
Co-authored-by: Dominik Dorfmeister <[email protected]>
1 parent 37c0774 commit 4b70794

11 files changed

+49
-49
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('focusManager', () => {
3939
expect(focusManager.isFocused()).toBeTruthy()
4040
})
4141

42-
it('should return true for isFocused if document is undefined', async () => {
42+
it('should return true for isFocused if document is undefined', () => {
4343
const { document } = globalThis
4444

4545
// @ts-expect-error
@@ -50,7 +50,7 @@ describe('focusManager', () => {
5050
globalThis.document = document
5151
})
5252

53-
test('cleanup (removeEventListener) should not be called if window is not defined', async () => {
53+
test('cleanup (removeEventListener) should not be called if window is not defined', () => {
5454
const restoreIsServer = setIsServer(true)
5555

5656
const removeEventListenerSpy = vi.spyOn(globalThis, 'removeEventListener')
@@ -64,7 +64,7 @@ describe('focusManager', () => {
6464
restoreIsServer()
6565
})
6666

67-
test('cleanup (removeEventListener) should not be called if window.addEventListener is not defined', async () => {
67+
test('cleanup (removeEventListener) should not be called if window.addEventListener is not defined', () => {
6868
const { addEventListener } = globalThis.window
6969

7070
// @ts-expect-error
@@ -81,7 +81,7 @@ describe('focusManager', () => {
8181
globalThis.window.addEventListener = addEventListener
8282
})
8383

84-
it('should replace default window listener when a new event listener is set', async () => {
84+
it('should replace default window listener when a new event listener is set', () => {
8585
const unsubscribeSpy = vi.fn().mockImplementation(() => undefined)
8686
const handlerSpy = vi.fn().mockImplementation(() => unsubscribeSpy)
8787

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ describe('dehydration and rehydration', () => {
580580
consoleMock.mockRestore()
581581
})
582582

583-
test('should not hydrate if the hydratedState is null or is not an object', async () => {
583+
test('should not hydrate if the hydratedState is null or is not an object', () => {
584584
const queryCache = new QueryCache()
585585
const queryClient = createQueryClient({ queryCache })
586586

@@ -590,7 +590,7 @@ describe('dehydration and rehydration', () => {
590590
queryClient.clear()
591591
})
592592

593-
test('should support hydratedState with undefined queries and mutations', async () => {
593+
test('should support hydratedState with undefined queries and mutations', () => {
594594
const queryCache = new QueryCache()
595595
const queryClient = createQueryClient({ queryCache })
596596

@@ -791,7 +791,7 @@ describe('dehydration and rehydration', () => {
791791
).toBe('idle')
792792
})
793793

794-
test('should dehydrate and hydrate mutation scopes', async () => {
794+
test('should dehydrate and hydrate mutation scopes', () => {
795795
const queryClient = createQueryClient()
796796
const onlineMock = mockOnlineManagerIsOnline(false)
797797

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ describe('InfiniteQueryBehavior', () => {
411411

412412
const observer = new InfiniteQueryObserver(queryClient, {
413413
queryKey: key,
414-
queryFn: async () => 'data',
414+
queryFn: () => 'data',
415415
getNextPageParam: () => null,
416416
initialPageParam: null,
417417
})

packages/query-core/src/__tests__/infiniteQueryObserver.test-d.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('InfiniteQueryObserver', () => {
1515
queryClient.clear()
1616
})
1717

18-
it('should be inferred as a correct result type', async () => {
18+
it('should be inferred as a correct result type', () => {
1919
const next: number | undefined = 2
2020
const queryFn = vi.fn(({ pageParam }) => String(pageParam))
2121
const observer = new InfiniteQueryObserver(queryClient, {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ describe('InfiniteQueryObserver', () => {
109109
expect(all).toEqual(['next0', 'next0,1', 'prev0,1'])
110110
})
111111

112-
test('should not invoke getNextPageParam and getPreviousPageParam on empty pages', async () => {
112+
test('should not invoke getNextPageParam and getPreviousPageParam on empty pages', () => {
113113
const key = queryKey()
114114

115115
const getNextPageParam = vi.fn()

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ describe('mutations', () => {
313313
expect(onSettled).toHaveBeenCalled()
314314
})
315315

316-
test('addObserver should not add an existing observer', async () => {
316+
test('addObserver should not add an existing observer', () => {
317317
const mutationCache = queryClient.getMutationCache()
318318
const observer = new MutationObserver(queryClient, {})
319319
const currentMutation = mutationCache.build(queryClient, {})

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ describe('notifyManager', () => {
2222
it('should use default batchNotifyFn', async () => {
2323
const notifyManagerTest = createNotifyManager()
2424
const callbackScheduleSpy = vi.fn().mockImplementation(() => sleep(20))
25-
const callbackBatchLevel2Spy = vi.fn().mockImplementation(async () => {
25+
const callbackBatchLevel2Spy = vi.fn().mockImplementation(() => {
2626
notifyManagerTest.schedule(callbackScheduleSpy)
2727
})
28-
const callbackBatchLevel1Spy = vi.fn().mockImplementation(async () => {
28+
const callbackBatchLevel1Spy = vi.fn().mockImplementation(() => {
2929
notifyManagerTest.batch(callbackBatchLevel2Spy)
3030
})
3131
notifyManagerTest.batch(callbackBatchLevel1Spy)
@@ -72,7 +72,7 @@ describe('notifyManager', () => {
7272
expect(notifySpy).toHaveBeenCalledTimes(1)
7373
})
7474

75-
it('typeDefs should catch proper signatures', async () => {
75+
it('typeDefs should catch proper signatures', () => {
7676
const notifyManagerTest = createNotifyManager()
7777

7878
// we define some fn with its signature:

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('onlineManager', () => {
5757
expect(remove2Spy).not.toHaveBeenCalled()
5858
})
5959

60-
test('cleanup (removeEventListener) should not be called if window is not defined', async () => {
60+
test('cleanup (removeEventListener) should not be called if window is not defined', () => {
6161
const restoreIsServer = setIsServer(true)
6262

6363
const removeEventListenerSpy = vi.spyOn(globalThis, 'removeEventListener')
@@ -71,7 +71,7 @@ describe('onlineManager', () => {
7171
restoreIsServer()
7272
})
7373

74-
test('cleanup (removeEventListener) should not be called if window.addEventListener is not defined', async () => {
74+
test('cleanup (removeEventListener) should not be called if window.addEventListener is not defined', () => {
7575
const { addEventListener } = globalThis.window
7676

7777
// @ts-expect-error
@@ -88,7 +88,7 @@ describe('onlineManager', () => {
8888
globalThis.window.addEventListener = addEventListener
8989
})
9090

91-
test('it should replace default window listener when a new event listener is set', async () => {
91+
test('it should replace default window listener when a new event listener is set', () => {
9292
const addEventListenerSpy = vi.spyOn(globalThis.window, 'addEventListener')
9393

9494
const removeEventListenerSpy = vi.spyOn(

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('query', () => {
6363

6464
const promise = queryClient.fetchQuery({
6565
queryKey: key,
66-
queryFn: async () => {
66+
queryFn: () => {
6767
count++
6868

6969
if (count === 3) {
@@ -109,7 +109,7 @@ describe('query', () => {
109109

110110
const promise = queryClient.fetchQuery({
111111
queryKey: key,
112-
queryFn: async () => {
112+
queryFn: () => {
113113
count++
114114

115115
if (count === 3) {
@@ -158,7 +158,7 @@ describe('query', () => {
158158

159159
const promise = queryClient.fetchQuery({
160160
queryKey: key,
161-
queryFn: async (): Promise<unknown> => {
161+
queryFn: (): Promise<unknown> => {
162162
count++
163163
throw new Error(`error${count}`)
164164
},
@@ -192,7 +192,7 @@ describe('query', () => {
192192
}
193193
})
194194

195-
test('should provide context to queryFn', async () => {
195+
test('should provide context to queryFn', () => {
196196
const key = queryKey()
197197

198198
const queryFn = vi
@@ -432,7 +432,7 @@ describe('query', () => {
432432
const key = queryKey()
433433
await queryClient.prefetchQuery({
434434
queryKey: key,
435-
queryFn: async () => 'data',
435+
queryFn: () => 'data',
436436
})
437437
const query = queryCache.find({ queryKey: key })!
438438
query.cancel()
@@ -511,7 +511,7 @@ describe('query', () => {
511511
const key = queryKey()
512512
const observer = new QueryObserver(queryClient, {
513513
queryKey: key,
514-
queryFn: async () => 'data',
514+
queryFn: () => 'data',
515515
gcTime: 0,
516516
})
517517
expect(queryCache.find({ queryKey: key })).toBeDefined()
@@ -547,7 +547,7 @@ describe('query', () => {
547547
const key = queryKey()
548548
const observer = new QueryObserver(queryClient, {
549549
queryKey: key,
550-
queryFn: async () => 'data',
550+
queryFn: () => 'data',
551551
gcTime: 0,
552552
})
553553
expect(queryCache.find({ queryKey: key })).toBeDefined()
@@ -562,9 +562,9 @@ describe('query', () => {
562562
expect(queryCache.find({ queryKey: key })).toBeDefined()
563563
})
564564

565-
test('should return proper count of observers', async () => {
565+
test('should return proper count of observers', () => {
566566
const key = queryKey()
567-
const options = { queryKey: key, queryFn: async () => 'data' }
567+
const options = { queryKey: key, queryFn: () => 'data' }
568568
const observer = new QueryObserver(queryClient, options)
569569
const observer2 = new QueryObserver(queryClient, options)
570570
const observer3 = new QueryObserver(queryClient, options)
@@ -659,7 +659,7 @@ describe('query', () => {
659659
)
660660
})
661661

662-
test('should refetch the observer when online method is called', async () => {
662+
test('should refetch the observer when online method is called', () => {
663663
const key = queryKey()
664664

665665
const observer = new QueryObserver(queryClient, {

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

+15-15
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('queryClient', () => {
3535
})
3636

3737
describe('defaultOptions', () => {
38-
test('should merge defaultOptions', async () => {
38+
test('should merge defaultOptions', () => {
3939
const key = queryKey()
4040

4141
const queryFn = () => 'data'
@@ -61,7 +61,7 @@ describe('queryClient', () => {
6161
expect(newQuery?.options.gcTime).toBe(Infinity)
6262
})
6363

64-
test('should get defaultOptions', async () => {
64+
test('should get defaultOptions', () => {
6565
const queryFn = () => 'data'
6666
const defaultOptions = { queries: { queryFn } }
6767
const testClient = createQueryClient({
@@ -72,7 +72,7 @@ describe('queryClient', () => {
7272
})
7373

7474
describe('setQueryDefaults', () => {
75-
test('should not trigger a fetch', async () => {
75+
test('should not trigger a fetch', () => {
7676
const key = queryKey()
7777
queryClient.setQueryDefaults(key, { queryFn: () => 'data' })
7878
const data = queryClient.getQueryData(key)
@@ -111,7 +111,7 @@ describe('queryClient', () => {
111111
expect(status).toBe('error')
112112
})
113113

114-
test('should also set defaults for observers', async () => {
114+
test('should also set defaults for observers', () => {
115115
const key = queryKey()
116116
queryClient.setQueryDefaults(key, {
117117
queryFn: () => 'data',
@@ -124,7 +124,7 @@ describe('queryClient', () => {
124124
expect(observer.getCurrentResult().fetchStatus).toBe('idle')
125125
})
126126

127-
test('should update existing query defaults', async () => {
127+
test('should update existing query defaults', () => {
128128
const key = queryKey()
129129
const queryOptions1 = { queryFn: () => 'data' }
130130
const queryOptions2 = { retry: false }
@@ -133,7 +133,7 @@ describe('queryClient', () => {
133133
expect(queryClient.getQueryDefaults(key)).toMatchObject(queryOptions2)
134134
})
135135

136-
test('should merge defaultOptions', async () => {
136+
test('should merge defaultOptions', () => {
137137
const key = queryKey()
138138

139139
queryClient.setQueryDefaults([...key, 'todo'], { suspense: true })
@@ -148,7 +148,7 @@ describe('queryClient', () => {
148148
})
149149

150150
describe('defaultQueryOptions', () => {
151-
test('should default networkMode when persister is present', async () => {
151+
test('should default networkMode when persister is present', () => {
152152
expect(
153153
createQueryClient({
154154
defaultOptions: {
@@ -160,7 +160,7 @@ describe('queryClient', () => {
160160
).toBe('offlineFirst')
161161
})
162162

163-
test('should not default networkMode without persister', async () => {
163+
test('should not default networkMode without persister', () => {
164164
expect(
165165
createQueryClient({
166166
defaultOptions: {
@@ -172,7 +172,7 @@ describe('queryClient', () => {
172172
).toBe(undefined)
173173
})
174174

175-
test('should not default networkMode when already present', async () => {
175+
test('should not default networkMode when already present', () => {
176176
expect(
177177
createQueryClient({
178178
defaultOptions: {
@@ -642,7 +642,7 @@ describe('queryClient', () => {
642642
await expect(
643643
queryClient.fetchQuery({
644644
queryKey: key,
645-
queryFn: async (): Promise<unknown> => {
645+
queryFn: (): Promise<unknown> => {
646646
throw new Error('error')
647647
},
648648
}),
@@ -923,7 +923,7 @@ describe('queryClient', () => {
923923

924924
const result = await queryClient.prefetchQuery({
925925
queryKey: key,
926-
queryFn: async (): Promise<unknown> => {
926+
queryFn: (): Promise<unknown> => {
927927
throw new Error('error')
928928
},
929929
retry: false,
@@ -937,7 +937,7 @@ describe('queryClient', () => {
937937

938938
await queryClient.prefetchQuery({
939939
queryKey: key,
940-
queryFn: async () => 'data',
940+
queryFn: () => 'data',
941941
gcTime: 10,
942942
})
943943
expect(queryCache.find({ queryKey: key })).toBeDefined()
@@ -973,7 +973,7 @@ describe('queryClient', () => {
973973
const key3 = queryKey()
974974
await queryClient.fetchQuery({
975975
queryKey: key1,
976-
queryFn: async () => 'data',
976+
queryFn: () => 'data',
977977
})
978978
try {
979979
await queryClient.fetchQuery({
@@ -1023,7 +1023,7 @@ describe('queryClient', () => {
10231023
const key1 = queryKey()
10241024
await queryClient.fetchQuery({
10251025
queryKey: key1,
1026-
queryFn: async () => 'data',
1026+
queryFn: () => 'data',
10271027
})
10281028
queryClient.fetchQuery({
10291029
queryKey: key1,
@@ -2029,7 +2029,7 @@ describe('queryClient', () => {
20292029
onlineManager.setOnline(true)
20302030
})
20312031

2032-
test('should not notify queryCache and mutationCache after multiple mounts/unmounts', async () => {
2032+
test('should not notify queryCache and mutationCache after multiple mounts/unmounts', () => {
20332033
const testClient = createQueryClient()
20342034
testClient.mount()
20352035
testClient.mount()

0 commit comments

Comments
 (0)