File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -889,12 +889,20 @@ describe('useQuery', () => {
889
889
expect ( results [ 2 ] ) . toMatchObject ( { data : 'fetched' , isFetching : false } )
890
890
} )
891
891
892
- it ( 'should update query stale state when invalidated with invalidateQueries' , async ( ) => {
892
+ it ( 'should update query stale state and refetch when invalidated with invalidateQueries' , async ( ) => {
893
893
const key = queryKey ( )
894
- const states : UseQueryResult < string > [ ] = [ ]
894
+ const states : UseQueryResult < number > [ ] = [ ]
895
+ let count = 0
895
896
896
897
function Page ( ) {
897
- const state = useQuery ( key , ( ) => 'data' , { staleTime : Infinity } )
898
+ const state = useQuery (
899
+ key ,
900
+ ( ) => {
901
+ count ++
902
+ return count
903
+ } ,
904
+ { staleTime : Infinity }
905
+ )
898
906
899
907
states . push ( state )
900
908
@@ -919,19 +927,19 @@ describe('useQuery', () => {
919
927
isStale : true ,
920
928
} )
921
929
expect ( states [ 1 ] ) . toMatchObject ( {
922
- data : 'data' ,
930
+ data : 1 ,
923
931
isFetching : false ,
924
932
isSuccess : true ,
925
933
isStale : false ,
926
934
} )
927
935
expect ( states [ 2 ] ) . toMatchObject ( {
928
- data : 'data' ,
936
+ data : 1 ,
929
937
isFetching : true ,
930
938
isSuccess : true ,
931
939
isStale : true ,
932
940
} )
933
941
expect ( states [ 3 ] ) . toMatchObject ( {
934
- data : 'data' ,
942
+ data : 2 ,
935
943
isFetching : false ,
936
944
isSuccess : true ,
937
945
isStale : false ,
You can’t perform that action at this time.
0 commit comments