title: How I can unit test if log is called
body: <p>I have such component. It is a wrapper component for another component. There is onClick function, which should call the log if is mouse event</p>
  
  <pre><code>import log from './log';
  
  export function withPressedLog(
      Component,
      options,
  ) {
      class WithPressedLogComponent extends React.Component {
          constructor(props) {
              super(props);
              this.onClick = this.onClick.bind(this);
          }
  
          public render() {
              const { ...props } = this.props;
              return &lt;Component {...props} onClick={this.onClick} /&gt;;
          }
  
          private onClick(e) {
              if (this.props.onClick !== undefined) {
                  this.props.onClick(e);
              }
  
              if (e) {
                  this.props.log();
              }
          }
      }
  
      const mapDispatchToProps = {
          log: () =&gt; log(options),
      };
  
      return connect(
          undefined,
          mapDispatchToProps,
      )(WithPressedLogComponent);
  }
  </code></pre>
  
  <p>I need to test is it called this.props.log. I have a unit test, but it not works. How I can do it using jest, enzyme?</p>
  
  <pre><code>it("should not log if has not mouse event", () =&gt; {
      const onClickMock = jest.fn();
      const logMock = jest.fn();
      const ButtonWithLog = withPressedLog(Button, {
          type: "BUTTON_PRESSED",
      });
  
      const subject = mountProvider(ButtonWithLog, { onClick: onClickMock, log: logMock });
  
      const mockedEvent = { target:{} };
      subject.find(ButtonWithLog).simulate("click", mockedEvent);
  
      expect(onClickMock.mock.calls).toHaveLength(1);
      expect(logMock.mock.calls).toHaveLength(0); // not works correctly, always return []
  
  });
  </code></pre>
  
  <p>store</p>
  
  <pre><code>const store = createStore(() =&gt; ({}));
  const dispatchMock = jest.fn();
  store.dispatch = dispatchMock;
  </code></pre>
  
  <p>mountProvider function</p>
  
  <pre><code>function mountProvider(
      Component,
      props,
  ) {
      return mount(
          &lt;Provider store={store}&gt;
              &lt;Component {...props} /&gt;
          &lt;/Provider&gt;,
      );
  }
  </code></pre>