title: How to test onClose prop with Jest and ReactJs
body: <p>I have a component looking like this, when the button is clicked a modal opens, when X button is clicked, mouse is pressed or esc key is pressed modal closes and calls <code>onClose</code> function, however, Jest report says <code>setIsOpen(false);</code> is not covered.</p>
  <pre><code>const MyComponent = () =&gt; {
    const [isOpen, setIsOpen] = useState(false);
   
    return (
      &lt;div className=&quot;container&quot;&gt;
            &lt;button
              onClick={() =&gt; {
                setIsOpen(true);
              }}
            /&gt;
        &lt;Flow
          isOpen={isOpen}
          onClose={() =&gt; {
            setIsOpen(false);
          }}
        /&gt;
      &lt;/div&gt;
    );
  }; 
  </code></pre>
  <p>How can I test if <code>setIsOpen(false);</code> is being called? I tried mocking the <code>useState</code> and check if it was being called, however, this messed up the <code>setIsOpen(true);</code> in the button, being a mock, the modal won't open.</p>
  <p>Any ideas?</p>