Skip to content

Commit 517c490

Browse files
authoredMar 31, 2025··
test(react-query): fix async to promise and remove unnecessary await (#8887)
1 parent 627062b commit 517c490

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed
 

Diff for: ‎packages/react-query/src/__tests__/useQueries.test.tsx

+15-13
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('useQueries', () => {
110110
expect(results[2]).toMatchObject([{ data: 2 }])
111111
})
112112

113-
it('handles type parameter - tuple of tuples', async () => {
113+
it('handles type parameter - tuple of tuples', () => {
114114
const key1 = queryKey()
115115
const key2 = queryKey()
116116
const key3 = queryKey()
@@ -215,7 +215,7 @@ describe('useQueries', () => {
215215
}
216216
})
217217

218-
it('handles type parameter - tuple of objects', async () => {
218+
it('handles type parameter - tuple of objects', () => {
219219
const key1 = queryKey()
220220
const key2 = queryKey()
221221
const key3 = queryKey()
@@ -389,7 +389,7 @@ describe('useQueries', () => {
389389
}
390390
})
391391

392-
it('handles array literal without type parameter to infer result type', async () => {
392+
it('handles array literal without type parameter to infer result type', () => {
393393
const key1 = queryKey()
394394
const key2 = queryKey()
395395
const key3 = queryKey()
@@ -676,17 +676,17 @@ describe('useQueries', () => {
676676
type QueryKeyA = ['queryA']
677677
const getQueryKeyA = (): QueryKeyA => ['queryA']
678678
type GetQueryFunctionA = () => QueryFunction<number, QueryKeyA>
679-
const getQueryFunctionA: GetQueryFunctionA = () => async () => {
680-
return 1
679+
const getQueryFunctionA: GetQueryFunctionA = () => () => {
680+
return Promise.resolve(1)
681681
}
682682
type SelectorA = (data: number) => [number, string]
683683
const getSelectorA = (): SelectorA => (data) => [data, data.toString()]
684684

685685
type QueryKeyB = ['queryB', string]
686686
const getQueryKeyB = (id: string): QueryKeyB => ['queryB', id]
687687
type GetQueryFunctionB = () => QueryFunction<string, QueryKeyB>
688-
const getQueryFunctionB: GetQueryFunctionB = () => async () => {
689-
return '1'
688+
const getQueryFunctionB: GetQueryFunctionB = () => () => {
689+
return Promise.resolve('1')
690690
}
691691
type SelectorB = (data: string) => [string, number]
692692
const getSelectorB = (): SelectorB => (data) => [data, +data]
@@ -805,7 +805,7 @@ describe('useQueries', () => {
805805
},
806806
{
807807
queryKey: key3,
808-
queryFn: async () => 2,
808+
queryFn: () => Promise.resolve(2),
809809
},
810810
{
811811
queryKey: key4,
@@ -866,7 +866,7 @@ describe('useQueries', () => {
866866
},
867867
{
868868
queryKey: key2,
869-
queryFn: async () => 2,
869+
queryFn: () => Promise.resolve(2),
870870
},
871871
{
872872
queryKey: key3,
@@ -989,10 +989,12 @@ describe('useQueries', () => {
989989
queries: ids.map((id) => {
990990
return {
991991
queryKey: [key, id],
992-
queryFn: async () => async () => {
993-
return {
994-
id,
995-
content: { value: Math.random() },
992+
queryFn: () => {
993+
return () => {
994+
return Promise.resolve({
995+
id,
996+
content: { value: Math.random() },
997+
})
996998
}
997999
},
9981000
}

0 commit comments

Comments
 (0)
Please sign in to comment.