@@ -568,17 +568,15 @@ describe('useQuery', () => {
568568
569569 await sleep ( 100 )
570570
571- expect ( states . length ) . toBe ( 5 )
571+ expect ( states . length ) . toBe ( 4 )
572572 // First load
573573 expect ( states [ 0 ] ) . toMatchObject ( { isLoading : true , isSuccess : false } )
574574 // First success
575575 expect ( states [ 1 ] ) . toMatchObject ( { isLoading : false , isSuccess : true } )
576- // Switch
577- expect ( states [ 2 ] ) . toMatchObject ( { isLoading : true , isSuccess : false } )
578576 // Second load
579- expect ( states [ 3 ] ) . toMatchObject ( { isLoading : true , isSuccess : false } )
577+ expect ( states [ 2 ] ) . toMatchObject ( { isLoading : true , isSuccess : false } )
580578 // Second success
581- expect ( states [ 4 ] ) . toMatchObject ( { isLoading : false , isSuccess : true } )
579+ expect ( states [ 3 ] ) . toMatchObject ( { isLoading : false , isSuccess : true } )
582580 } )
583581
584582 it ( 'should fetch when refetchOnMount is false and nothing has been fetched yet' , async ( ) => {
@@ -768,17 +766,15 @@ describe('useQuery', () => {
768766
769767 await sleep ( 20 )
770768
771- expect ( states . length ) . toBe ( 5 )
769+ expect ( states . length ) . toBe ( 4 )
772770 // Initial
773771 expect ( states [ 0 ] ) . toMatchObject ( { data : undefined } )
774772 // Fetched
775773 expect ( states [ 1 ] ) . toMatchObject ( { data : 1 } )
776- // Rerender
777- expect ( states [ 2 ] ) . toMatchObject ( { data : undefined } )
778774 // Switch
779- expect ( states [ 3 ] ) . toMatchObject ( { data : undefined } )
775+ expect ( states [ 2 ] ) . toMatchObject ( { data : undefined } )
780776 // Fetched
781- expect ( states [ 4 ] ) . toMatchObject ( { data : 2 } )
777+ expect ( states [ 3 ] ) . toMatchObject ( { data : 2 } )
782778 } )
783779
784780 it ( 'should be create a new query when refetching a removed query' , async ( ) => {
@@ -1084,7 +1080,7 @@ describe('useQuery', () => {
10841080
10851081 renderWithClient ( queryClient , < Page /> )
10861082
1087- await waitFor ( ( ) => expect ( states . length ) . toBe ( 5 ) )
1083+ await waitFor ( ( ) => expect ( states . length ) . toBe ( 4 ) )
10881084
10891085 // Initial
10901086 expect ( states [ 0 ] ) . toMatchObject ( {
@@ -1107,15 +1103,8 @@ describe('useQuery', () => {
11071103 isSuccess : true ,
11081104 isPreviousData : true ,
11091105 } )
1110- // Previous data
1111- expect ( states [ 3 ] ) . toMatchObject ( {
1112- data : 0 ,
1113- isFetching : true ,
1114- isSuccess : true ,
1115- isPreviousData : true ,
1116- } )
11171106 // New data
1118- expect ( states [ 4 ] ) . toMatchObject ( {
1107+ expect ( states [ 3 ] ) . toMatchObject ( {
11191108 data : 1 ,
11201109 isFetching : false ,
11211110 isSuccess : true ,
@@ -1152,7 +1141,7 @@ describe('useQuery', () => {
11521141
11531142 renderWithClient ( queryClient , < Page /> )
11541143
1155- await waitFor ( ( ) => expect ( states . length ) . toBe ( 5 ) )
1144+ await waitFor ( ( ) => expect ( states . length ) . toBe ( 4 ) )
11561145
11571146 // Initial
11581147 expect ( states [ 0 ] ) . toMatchObject ( {
@@ -1175,15 +1164,8 @@ describe('useQuery', () => {
11751164 isSuccess : true ,
11761165 isPreviousData : true ,
11771166 } )
1178- // Previous data
1179- expect ( states [ 3 ] ) . toMatchObject ( {
1180- data : 0 ,
1181- isFetching : true ,
1182- isSuccess : true ,
1183- isPreviousData : true ,
1184- } )
11851167 // New data
1186- expect ( states [ 4 ] ) . toMatchObject ( {
1168+ expect ( states [ 3 ] ) . toMatchObject ( {
11871169 data : 1 ,
11881170 isFetching : false ,
11891171 isSuccess : true ,
@@ -1228,7 +1210,7 @@ describe('useQuery', () => {
12281210
12291211 renderWithClient ( queryClient , < Page /> )
12301212
1231- await waitFor ( ( ) => expect ( states . length ) . toBe ( 7 ) )
1213+ await waitFor ( ( ) => expect ( states . length ) . toBe ( 6 ) )
12321214
12331215 // Disabled query
12341216 expect ( states [ 0 ] ) . toMatchObject ( {
@@ -1258,22 +1240,15 @@ describe('useQuery', () => {
12581240 isSuccess : true ,
12591241 isPreviousData : true ,
12601242 } )
1261- // Switched query key
1262- expect ( states [ 4 ] ) . toMatchObject ( {
1263- data : 0 ,
1264- isFetching : false ,
1265- isSuccess : true ,
1266- isPreviousData : true ,
1267- } )
12681243 // Fetching new query
1269- expect ( states [ 5 ] ) . toMatchObject ( {
1244+ expect ( states [ 4 ] ) . toMatchObject ( {
12701245 data : 0 ,
12711246 isFetching : true ,
12721247 isSuccess : true ,
12731248 isPreviousData : true ,
12741249 } )
12751250 // Fetched new query
1276- expect ( states [ 6 ] ) . toMatchObject ( {
1251+ expect ( states [ 5 ] ) . toMatchObject ( {
12771252 data : 1 ,
12781253 isFetching : false ,
12791254 isSuccess : true ,
@@ -1324,7 +1299,7 @@ describe('useQuery', () => {
13241299
13251300 await sleep ( 100 )
13261301
1327- expect ( states . length ) . toBe ( 6 )
1302+ expect ( states . length ) . toBe ( 5 )
13281303
13291304 // Disabled query
13301305 expect ( states [ 0 ] ) . toMatchObject ( {
@@ -1340,29 +1315,22 @@ describe('useQuery', () => {
13401315 isSuccess : true ,
13411316 isPreviousData : true ,
13421317 } )
1343- // Switched query key
1344- expect ( states [ 2 ] ) . toMatchObject ( {
1345- data : 10 ,
1346- isFetching : false ,
1347- isSuccess : true ,
1348- isPreviousData : true ,
1349- } )
13501318 // Set state
1351- expect ( states [ 3 ] ) . toMatchObject ( {
1319+ expect ( states [ 2 ] ) . toMatchObject ( {
13521320 data : 10 ,
13531321 isFetching : false ,
13541322 isSuccess : true ,
13551323 isPreviousData : true ,
13561324 } )
13571325 // Switched query key
1358- expect ( states [ 4 ] ) . toMatchObject ( {
1326+ expect ( states [ 3 ] ) . toMatchObject ( {
13591327 data : 10 ,
13601328 isFetching : true ,
13611329 isSuccess : true ,
13621330 isPreviousData : true ,
13631331 } )
13641332 // Refetch done
1365- expect ( states [ 5 ] ) . toMatchObject ( {
1333+ expect ( states [ 4 ] ) . toMatchObject ( {
13661334 data : 12 ,
13671335 isFetching : false ,
13681336 isSuccess : true ,
@@ -2126,13 +2094,11 @@ describe('useQuery', () => {
21262094
21272095 await sleep ( 100 )
21282096
2129- expect ( states . length ) . toBe ( 3 )
2097+ expect ( states . length ) . toBe ( 2 )
21302098 // Initial
21312099 expect ( states [ 0 ] ) . toMatchObject ( { data : { count : 0 } } )
21322100 // Set state
21332101 expect ( states [ 1 ] ) . toMatchObject ( { data : { count : 1 } } )
2134- // Update
2135- expect ( states [ 2 ] ) . toMatchObject ( { data : { count : 1 } } )
21362102 } )
21372103
21382104 it ( 'should retry specified number of times' , async ( ) => {
0 commit comments