title: Test useInterval inner logic with jest and @testing-library/react
body: <p>I have component that uses useInterval hook from <a href="https://github.com/streamich/react-use" rel="nofollow noreferrer">react-use repo</a>
  Inside hook callback I have next logic</p>
  <pre><code>const [currentIndex, setCurrentIndex] = useState(0)
  
    const runIntervalRef = useRef(minInterval)
  
    useInterval(() =&gt; {
      if (runIntervalRef.current &gt;= maxInterval) {
        const nextIndex =
          data_list.length &gt; currentIndex + 1 ? currentIndex + 1 : 0
        setCurrentIndex(nextIndex)
        runIntervalRef.current = minInterval
      } else {
        runIntervalRef.current = runIntervalRef.current + minInterval
      }
    }, minInterval)
  </code></pre>
  <p>The jest coverage shows me that I have to add mock for logic inside useInterval.</p>
  <p>I tried to mock useRef and spy on ref current value, but still coverage stayed the same
  What is the right way to do test for such issue?</p>