Using Jest to test a React component's method
<p>I have a container component responsible for providing save functionality for a child form component method. I'm trying to use Jest &amp; Enzyme (I think I need enzyme?) to test whether the child component fires the function passed from the parent component. The two methods look like so:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>class Parent extends Component {
  handleSave = (someData) =&gt; (
    /* do some ajax with someData */
  )
  render() {
    return(
      &lt;ChildComponent {...this.props} handleSave={this.handleSave} /&gt;
    )
  }
}

class ChildComponent extends Component {
  render() {
    &lt;form onSubmit={this.props.handleSave}&gt;
      &lt;button type="submit"&gt;Submit&lt;/button&gt;
    &lt;/form&gt;
  }
}</code></pre>
</div>
</div>
</p>

<p>And the test:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import React from 'react'
import ParentContainer from '../src/ParentContainer'

describe('&lt;ParentContainer /&gt;', () =&gt; {

  it('Should fire handle save when PatientScheduler form saves', () =&gt; {
    const component = mount( &lt;ParentContainer /&gt;)
    component.handleSave = jest.fn()
    component.find('[type="submit"]').simulate('click')
    expect(component.handleSave).toHaveBeenCalled()
  })

})</code></pre>
</div>
</div>
</p>

<p>The failure message I'm getting is <code>Expected mock function to have been called.</code></p>

<p>I feel like I'm 90% of the way there. What's wrong here? Thank you.</p>