title: Testing parent methods in stateless child component in Jest
body: <p>I currently have a react component with an <code>onChange</code> method. </p>
  
  <p>I want to test the onChange method like if someone were to type in, or paste things in. The problem is the <code>handleChange</code> is dependent on the parent components using it. What's the best way to test for the simulation? Do I need to reference the parent component's <code>handleChange</code> method and simulate that? </p>
  
  <p>CodeSandbox (i didn't add the tests here)</p>
  
  <p><a href="https://codesandbox.io/s/react-basic-example-cwdh1?from-embed" rel="nofollow noreferrer">https://codesandbox.io/s/react-basic-example-cwdh1?from-embed</a></p>
  
  <p>Updated Current Test:</p>
  
  <pre><code>const handleChange = jest.fn();
  
  const initProps = {
    name: "Title",
    label: "Body",
    type: "text",
    value: "",
    handleChange
  };
  
  describe("TextBox", () =&gt; {
      let wrapper;
      beforeEach(() =&gt; {
        wrapper = mount(&lt;TextBox {...props} /&gt;);
      });
  
      afterEach(() =&gt; {
        // resets the mocked fn after each test
        handleChange.mockClear();
      });
  
      it("should call handleChange with a new value", () =&gt; {
        const value = "testing input";
        wrapper.find("input").simulate("change", { target: { value } });
  
        expect(handleChange).toHaveBeenCalledWith(value);
      });
    });
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Expected: "testing input"
  Received: {"_dispatchInstances": null, "_dispatchListeners": null,
   "_targetInst": ......more fields... "nativeEvent": {"target": &lt;input … /&gt;,
   "type": "change"}, "target": {"value": "testing input"}, "timeStamp":
   1576040322012, "type": "change"}
  </code></pre>
  
  <p>I know I'm getting this error because the value is coming out of the formfields. Is there a way I can extract the target field out? </p>