title: Testing onClose event from a component to be called using jest
body: <p>I am doing tests for a react component using jest and enzyme and haven't figured out how to test the onClose event from the material-ui Menu. The same should apply to other components but we can stick with the Menu for the sake of this question.
  Here it is my component:</p>
  <pre><code>import { Menu, MenuItem } from &quot;@material-ui/core&quot;;
  
  export class ItemPreviewerPage extends React.Component&lt;ComponentProps, ComponentState&gt; {
    constructor(props) {
      super(props);
      this.state = {
          anchorEl: undefined,
          fieldsetMenu: undefined,
          isColumnSelectorOpen: false,
      };
    }
    
    render() {
      const { classes } = this.props;
      const moreMenuOpen = Boolean(this.state.anchorEl);
      
      return (
          &lt;Menu className={classes.cardMenu}
                id=&quot;long-menu&quot;
                anchorEl={this.state.anchorEl}
                open={moreMenuOpen}
                onClose={() =&gt; this.handleClose()}
                PaperProps={{
                  style: {
                      maxHeight: 48 * 4.5,
                      width: 200
                  }
                 }}&gt;
          &lt;/Menu&gt;
      );
    }
  }
  </code></pre>
  <p>and for the test, I was expecting the Menu to be closed if I set the state of the anchorEl to true and then to false.</p>
  <pre><code>it(&quot;Calls the handleClose when the Menu is closed&quot;, () =&gt; {
      const props = initialProps;
  
      const wrapper = shallow(&lt;ItemPreviewerPage {...props} /&gt;);
      const spy = jest.spyOn(wrapper.instance(), &quot;handleClose&quot;);
  
      wrapper.setState({ anchorEl: true });
      wrapper.instance().forceUpdate();        
      wrapper.setState({ anchorEl: false });
      wrapper.instance().forceUpdate();
  
      expect(spy).toBeCalled();
  });
  </code></pre>
  <p>What's wrong? How can I test the onClose?</p>