File tree Expand file tree Collapse file tree
packages/query-core/src/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -747,6 +747,24 @@ describe('queryObserver', () => {
747747 expect ( count ) . toBe ( 2 )
748748 } )
749749
750+ it ( 'should refetch at the interval returned when refetchInterval is a function' , async ( ) => {
751+ const key = queryKey ( )
752+ let count = 0
753+ const observer = new QueryObserver ( queryClient , {
754+ queryKey : key ,
755+ queryFn : ( ) => {
756+ count ++
757+ return Promise . resolve ( 'data' )
758+ } ,
759+ refetchInterval : ( ) => 10 ,
760+ } )
761+ const unsubscribe = observer . subscribe ( ( ) => undefined )
762+ expect ( count ) . toBe ( 1 )
763+ await vi . advanceTimersByTimeAsync ( 10 )
764+ expect ( count ) . toBe ( 2 )
765+ unsubscribe ( )
766+ } )
767+
750768 it ( 'should use placeholderData as non-cache data when pending a query with no data' , async ( ) => {
751769 const key = queryKey ( )
752770 const observer = new QueryObserver ( queryClient , {
You can’t perform that action at this time.
0 commit comments