Skip to content

Commit 56fc5f4

Browse files
committed
fix(core): do not refetch disabled queries
update test to make more sense - title said disabled queries, but we had no disabled query; test now does the opposite of what it did before, but that's what this PR does :)
1 parent 133cd0c commit 56fc5f4

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

src/reactjs/tests/useQuery.test.tsx

+7-16
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ describe('useQuery', () => {
12691269
})
12701270
})
12711271

1272-
it('should update disabled query when updated with refetchQueries', async () => {
1272+
it('should not update disabled query when refetched with refetchQueries', async () => {
12731273
const key = queryKey()
12741274
const states: UseQueryResult<number>[] = []
12751275
let count = 0
@@ -1282,7 +1282,7 @@ describe('useQuery', () => {
12821282
count++
12831283
return count
12841284
},
1285-
{ staleTime: Infinity, initialData: 99 }
1285+
{ enabled: false }
12861286
)
12871287

12881288
states.push(state)
@@ -1298,23 +1298,14 @@ describe('useQuery', () => {
12981298

12991299
renderWithClient(queryClient, <Page />)
13001300

1301-
await sleep(100)
1301+
await sleep(50)
13021302

1303-
expect(states.length).toBe(3)
1303+
expect(states.length).toBe(1)
13041304
expect(states[0]).toMatchObject({
1305-
data: 99,
1306-
isFetching: false,
1307-
isSuccess: true,
1308-
})
1309-
expect(states[1]).toMatchObject({
1310-
data: 99,
1311-
isFetching: true,
1312-
isSuccess: true,
1313-
})
1314-
expect(states[2]).toMatchObject({
1315-
data: 1,
1305+
data: undefined,
13161306
isFetching: false,
1317-
isSuccess: true,
1307+
isSuccess: false,
1308+
isStale: true,
13181309
})
13191310
})
13201311

0 commit comments

Comments
 (0)