Redux: How to test a connected component?
<p>I am using <code>Enzyme</code> to unit test my React components. I understand that in order to test the raw unconnected component I'd have to just export it and test it (I've done that). I have managed to write a test for the connected component but I am really not sure if this's the right way and also what exactly would I want to test for the connected component. </p>

<p><strong>Container.jsx</strong></p>

<pre><code>import {connect} from 'react-redux';
import Login from './Login.jsx';
import * as loginActions from './login.actions';

const mapStateToProps = state =&gt; ({
  auth: state.auth
});
const mapDispatchToProps = dispatch =&gt; ({
  loginUser: credentials =&gt; dispatch(loginActions.loginUser(credentials))

});
export default connect(mapStateToProps, mapDispatchToProps)(Login);
</code></pre>

<p><strong>Container.test.js</strong></p>

<pre><code>import React from 'react';
import {Provider} from 'react-redux';
import {mount, shallow} from 'enzyme';
import {expect} from 'chai';
import LoginContainer from '../../src/login/login.container';
import Login from '../../src/login/Login';


describe('Container Login', () =&gt; {
  it('should render the container component', () =&gt; {
    const storeFake = state =&gt; ({
      default: () =&gt; {
      },
      subscribe: () =&gt; {
      },
      dispatch: () =&gt; {
      },
      getState: () =&gt; ({ ...state })
    });
    const store = storeFake({
      auth: {
        sport: 'BASKETBALL'
      }
    });

    const wrapper = mount(
      &lt;Provider store={store}&gt;
        &lt;LoginContainer /&gt;
      &lt;/Provider&gt;
    );

    expect(wrapper.find(LoginContainer).length).to.equal(1);
    const container = wrapper.find(LoginContainer);
    expect(container.find(Login).length).to.equal(1);
    expect(container.find(Login).props().auth).to.eql({ sport: 'BASKETBALL' });
  });
});
</code></pre>