title: How to write test case to if Condition which is in UseEffect in react js
body: <p>I am new to unit testing, I tried writing this simple test case but not able to do it.
  Could some one help me to write test case for if condition in useEffect.</p>
  <pre><code>import React, { useEffect } from &quot;react&quot;;
  import { useDispatch, useSelector } from &quot;react-redux&quot;;
      
  const Greet = () =&gt; {
        const dispatch = useDispatch();
        //I am getting data from redux file
        const stateData = useSelector((state) =&gt; state.stateDatalist);
        const countryData = useSelector((state) =&gt; state.CountryDatalist);
        useEffect(() =&gt; {
          if (stateData.length === 0 &amp;&amp; countryData.length === 0) {
            // calling another API data
            dispatch(getDetails());
          }
        }, []);
      
        return (
          &lt;div&gt;
            &lt;h1&gt;Hello&lt;/h1&gt;
          &lt;/div&gt;
        );
  };
      
  export default Greet;
  </code></pre>