title: Testing handle change function in React using Enzyme and Jest
body: <p>My react component contains this code </p>
  
  <pre><code> handleChange = e =&gt; {
      this.setState({
        num: e.target.value
      });
    };
  
    render() {
      return (
        &lt;div&gt;
          &lt;h2&gt;Delete cat :(&lt;/h2&gt;
          &lt;input
            onChange={this.handleChange}
            type="number"
            placeholder="enter id here"
          /&gt;
          &lt;button id="deleteBtn" onClick={this.deleteOne}&gt;
            Delete
          &lt;/button&gt;
        &lt;/div&gt;
      );
    }
  }
  </code></pre>
  
  <p>As you can see, the handleChange function fires when the input changes and will update state from there. </p>
  
  <p>How can I test this using Enzyme? I've tried</p>
  
  <pre><code> it("Updates the state", () =&gt; {
       const wrapper = shallow(
         &lt;Provider store={store}&gt;
           &lt;DeleteOne /&gt;
         &lt;/Provider&gt;
       );
       const input = wrapper.find("input");
  
       input.simulate("change", { target: { num: 2} });
  
       expect(wrapper.state().num).toEqual(2);
     });
  });
  </code></pre>
  
  <p>I had to attempt to wrap it in store because I'm using Redux and exporting a connected component. I've been Googling the last hour and trying all sorts but weren't able to get this test passing. Please send help :) cheers</p>
  
  <p>PS: I've tested the button click no worries as it just runs a function (no state update).</p>