title: How to write a jest test for the router.listen callback
body: <p>How do you go about testing the router.listen callback?</p>
  <p>I've got this below code:</p>
  <pre><code>  if (router) {
      router.listen(() =&gt; {
        updatedResource = updateResource(resource, checkedOverrides);
      });
    }
  </code></pre>
  <p>I've managed to test the calling of the router.listen method but to get 100% coverage I need to also test if the updateResource method gets called which gets imported into the file as a child export.</p>
  <p><code>import { updateResource } from 'path'</code></p>
  <p>I tried to spy on it to see if it got called but this did not work. Below is an example of the test that I have written so far:</p>
  <pre><code>  it('should call the listen method when router exists.', () =&gt; {
      // const mockedUpdateResource = updateResource;
      // console.log(updateResource());
  
      const router = {
        listen: jest.fn(),
      };
  
      window.history.pushState({}, '', '/?Colour%20group=White');
      wrapper = shallow(&lt;RangeParent consumer={consumer} resource={WCMSdata} router=    {router} /&gt;);
  
      // const spy = jest.spyOn(updateResource, 'updateResource');
      // window.history.pushState({}, '', '/');
      // const spy = jest.spyOn(updateResource);
  
      expect(router.listen).toHaveBeenCalled();
    });
  </code></pre>