title: Coverage by Jest tests of a React component to call a function when a button is clicked
body: <p>I have a functional React component that renders a button that, when clicked, calls a handleSave function from the props with a passed argument. I try to cover the component with tests, but I can't win, the test crashes in the console with an error that the function was not called. Attached the component and test code:</p>
  <pre><code>// component
  function Modal(props) {
    const { handleSave } = props;
  
    return (
      &lt;button onClick={() =&gt; {handleSave('someInfo')}}&gt;Save&lt;/button&gt;
    )
  }
  
  // test
  describe('ModalComponent', () =&gt; {
    it('should call handleSave function', () =&gt; {
      const onSaveClickMock = jest.fn();
  
      const component = mount(&lt;Modal handleSave={onSaveClickMock} /&gt;);
      const button = component.find('button');
      button.simulate('click');
      expect(onSaveClickMock).toHaveBeenCalled();
    })
  })
  </code></pre>
  <p>As I understand it, this test implementation would work if the handleSave function was directly passed to onClick like this:</p>
  <pre><code>&lt;button onClick={handleSave}&gt;Save&lt;/button&gt;
  </code></pre>
  <p>How can I implement a test when the function is not just passed to the onClick attribute, but called with the passed argument?</p>