Enzyme/Mocha: How to test a react component function by firing an onChange event from a child component
<p>I'm using enzyme/mocha to test my react component.</p>

<p>I have a parent component  which I am testing.</p>

<pre><code>let wrapper = mount(&lt;Parent /&gt;);
</code></pre>

<p>and this parent has a child component in it's render function </p>

<pre><code>render: function() {
    &lt;Child onChange={this.foo} /&gt;
},
foo: function() {
    console.log("I was called");
}
</code></pre>

<p>I would like the child's onChange function to fire so that I can test my parents foo function. </p>

<p>So far, I have found no way to do this - I've read about sinon and stubbing but that's mostly about intercepting functions and not firing them.</p>

<p>The following test</p>

<pre><code>shallow(&lt;Parent /&gt;).instance().foo();
</code></pre>

<p>is a weak test because it doesn't test the line of code connecting my child and parent, and in case I haven't written a unit test for my child, it doesn't test the child's onChange functionality either. IMHO - If breaking up my components to parents/children means less testability - then something is wrong with this framework </p>

<p>Any help will be appreciated, thanks</p>