title: How to write unit test for ipcRenderer.on and ipcRenderer.send in Jest?
body: <p>Hi I have developing a project using Electron and React,</p>
  
  <p>I have a form in react side which on submit calls the <code>ipcRenderer.on</code> an <code>ipcRenderer.send</code> method.</p>
  
  <p>I am having difficulty writing unit test code for form submit function. the function is as follows.</p>
  
  <pre><code>  handleFormSubmit = () =&gt; {
      const ethData = this.state.data;
      ipcRenderer.on('asynchronous-reply', (event, arg) =&gt; {
        if (arg === 'success') {
          this.setState({ status: true });
        }
      });
      ipcRenderer.send('update', value);
    }
  </code></pre>
  
  <p>First i just wanted to test that on click of save button handleFormSubmit function is called.
  What I wrote is - </p>
  
  <pre><code>it('calls handleFormSubmit method when the form is submitted', () =&gt; {
    const instance = wrapped.instance();
    wrapped.find('button').simulate('click');
    expect(instance.handleFormSubmit()).toHaveBeenCalled();
  });
  </code></pre>
  
  <p>The error I am getting is  </p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'on' of undefined.</p>
  </blockquote>