title: Unable to write unit test case for button click event
body: <p>I am working on the React JS application. Whenever the user presses Enter I am firing some event as below.</p>
  
  <pre><code>dispatchSearch() {
      if (!this.isSearchButtonDisabled()) {
        const searchTerms = { [this.state.searchType]: this.state.searchTerm };
        const searchDbTarget = '';
        const options = {};
        this.props.searchParameters(searchTerms, searchDbTarget, options, this.state.allOpenStoresSearchTerms.selectedOption);
      }
    }
  </code></pre>
  
  <p>The above code works as expected. Below is my unit test case for the above code.</p>
  
  <pre><code> it('should dispatch a keycode when keycode value is set', () =&gt; {
      component.setState({ searchTerm: 'some-value', allOpenStoresSearchTerms: {selectedOption: {value: 'true', label: 'Open Stores'}} });
      component.find('SearchInput').props().onKeyPress({ key: 'Enter' });
      expect(dispatchEvent).toBeCalled();
      expect(dispatchEvent).toBeCalledWith({ simsKeycode: 'some-value', allOpenStoresSearchTerms: {selectedOption: {value: 'true', label: 'Open Stores'}} });
    });
  </code></pre>
  
  <p>This unit test case fails and throws below error</p>
  
  <blockquote>
    <p>Expected mock function to have been called with:
          {"allOpenStoresSearchTerms": {"selectedOption": {"label": "Open Stores", "value": "true"}}, "simsKeycode": "some-value"} as argument
    1, but it was called with {"simsKeycode": "some-value"}.
          undefined as argument 2, but it was called with "".
          undefined as argument 3, but it was called with {}.
          undefined as argument 4, but it was called with {"label": "Open Stores", "value": "true"}.</p>
  </blockquote>
  
  <p>May I know what I am missing in the above code? Any help would be greatly appreciated. Thanks </p>