title: Using useEffect() hook to test a function in Jest
body: <p>I'm learning Jest basically, I have to write a test case for the useEffect() hook which renders based on a flag[counter], and which internally checks if a localStorage value is present for a field.</p>
  
  <pre><code>function sample(props) {
    const counter = props;
    const [displayIcon, setDisplayIcon] = useState(counter);
  
    function isLocalstoragePresent() {    
      return localStorage.getItem("some_Id");
    }
  
    useEffect(() =&gt; {
      if (isLocalstoragePresent()) {
        setDisplayIcon(true);
      } else {
        setDisplayIcon(false);
      }
    }, [counter]);
  
   export default sample;
  </code></pre>
  
  <p>Can some one help me in writing test case/provide a guidence for the UseEffect which internally calls isLocalstoragePresent() method aswell. Thanks in advance.</p>