title: Testing react component enclosed in withRouter (preferably using jest/enzyme)
body: <p>I have a React component which is enclosed within Higher Order Component withRouter as below:</p>
  
  <pre><code>module.exports = withRouter(ManageProfilePage);
  </code></pre>
  
  <p>My routes are as below:</p>
  
  <pre><code>&lt;Route path="/" component={AdrApp}&gt;
      &lt;IndexRoute component={Login}/&gt;
      &lt;Route component={CheckLoginStatus}&gt;
          &lt;Route path="manage-profiles/:profileId" component=
          {ManageProfilesPage}/&gt;
       &lt;/Route&gt;
      &lt;Route path="*" component={notFoundPage}/&gt;
  &lt;/Route&gt;
  </code></pre>
  
  <p>I need to use once of the Router lifecycle methods, that is why I need withRouter:</p>
  
  <pre><code>class ManageProfilePage extends React.Component {
      componentDidMount() {
      this.props.router.setRouteLeaveHook(this.props.route, () =&gt; {
        ...
      })
      render(){
      ... 
      }
  }
  </code></pre>
  
  <p>I need to test this component using Jest/Enzyme and I wrote the test case as below:</p>
  
  <pre><code>describe('manage profile page test suite', () =&gt; {
  
  
      it('snapshot test', () =&gt; {
  
          const setRouteLeaveHook =jest.fn();
  
          let wrapper = shallow(
              &lt;ManageProfilePage params={{id : 25, router: 
          setRouteLeaveHook}}/&gt;
          );
        expect(wrapper).toMatchSnapshot();
      })
     }) 
  </code></pre>
  
  <p>The issue is it is not rendering one level deep. I am pasting the snapshot below:</p>
  
  <pre><code>exports[`manage drug term page test suites snapshot test 1`] = `
  &lt;ManageProfilePage
    params={
      Object {
        "id": 25,
        "router": [Function],
      }
    }
  /&gt;
  `;
  </code></pre>
  
  <p>Is there any different way I can write my test case so that I am able to render ManageProfilePage atleast 1 level deep? It is not able to render as it is enclosed within WithRouter? How do we test these type of components?</p>