title: React Redux: Testing mapStateToProps and mapDispatchToProps with Enzyme/Jest
body: <p>So I would like to test <code>mapStateToProps</code> and <code>mapDispatchToProps</code> with Enzyme/Jest.</p>
  
  <p>I have a component DrawerAvatar like this:</p>
  
  <p><strong>DrawerAvatar.js</strong></p>
  
  <pre><code>const mapStateToProps = state =&gt; ({
    isAuthenticated: state.authReducer.isAuthenticated
  });
  
  export default compose(
    connect(mapStateToProps, null)
  )(DrawerAvatar);
  </code></pre>
  
  <p><strong>DrawerAvatar.test.js</strong></p>
  
  <pre><code>import configureMockStore from 'redux-mock-store';
  import connectedDrawerAvatar, { DrawerAvatar } from './DrawerAvatar';
  
  const mockStore = configureMockStore();
  
  it('mapStateToProps should return the right value', () =&gt; {
    const initialState = {
      someState: 123
    };
    const store = mockStore(initialState);
    const wrapper = shallow(&lt;connectedDrawerAvatar store={store} /&gt;);
    expect(wrapper.props().someState).toBe(123);
  });
  </code></pre>
  
  <p>However, this doesn't work because <code>wrapper.props().someState</code> returns <code>undefined</code>... So I have no clue how to test mapStatesToProps along with redux-mock-store using the connected component.</p>
  
  <p>I don't know neither how to test mapDispatchToProps ..! 
  I've tried the methods providing in this <a href="https://jsramblings.com/2018/01/15/3-ways-to-test-mapStateToProps-and-mapDispatchToProps.html" rel="noreferrer">blog</a> but it doesn't work.</p>
  
  <p>Thank you very much ! </p>
  
  <p><strong>EDIT</strong>:
  This works, but I'm not sure if it <strong>really tests</strong> the mapStateToProps... Can someone confirm that this is the right way to test mapStateToProps ? 
  <strong>DrawerAvatar.test.js</strong></p>
  
  <pre><code>  it('mapStateToProps should return the right value', () =&gt; {
      const initialState = {
        isAuthenticated: false
      };
      const mockStore = configureMockStore();
      const store = mockStore(initialState);
  
      const wrapper = shallow(&lt;connectedDrawerAvatar store={store} /&gt;);
      expect(wrapper.props().store.getState().isAuthenticated).toBe(false);
    });
  </code></pre>