title: How to test that a component calls a function prop with another component as argument?
body: <p>I have a component that receives a function as a prop and passes a rendered element to it, on mount:</p>
  <pre><code>function MyComponent(props) {
    useEffect(() =&gt; {
      props.onHeaderChange(&lt;button&gt;Back&lt;/button&gt;)
    }, [])
  
    return (&lt;div&gt;My Component&lt;/div&gt;)
  }
  </code></pre>
  <p>I want to write a test for checking that the back button is passed:</p>
  <pre><code>test(&quot;it renders the back button&quot;, () =&gt; {
    const onHeaderChange = jest.fn()
    const { getByText } = render(
      &lt;MyComponent {...props} onHeaderChange={onHeaderChange} /&gt;
    )
  
    expect(onHeaderChange).toHaveBeenCalledWith(&quot;How to test for the back button here?&quot;)
  })
  </code></pre>
  <p>But I'm not sure what the jest / react testing library syntax is for it?</p>