title: redux-saga-test-plan expectSaga- Testing reducer with state branch
body: <p>I am having a bit of trouble properly testing my saga. The issue stems from the fact that when running the saga, the reducer is mounted at <code>state: {...initialState}</code> whereas my saga <code>select</code> effects are expecting the reducer mounted at <code>state: {authentication: {...initialState}}</code></p>
  
  <p>Due to this I am unable to fully test the reducer/saga combo, since the shape of the final state object is inconsistent with the actual shape of the store.</p>
  
  <p>The saga being tested:</p>
  
  <pre><code>export default function* rootAuthenticationSaga() {
    while (true) {
        refreshToken = yield select((state: ApplicationRootState) =&gt; state.authentication.refreshToken);
        ... more code here
  }
  
  </code></pre>
  
  <p>One of my test is as follows:</p>
  
  <pre><code>    test('logs the user in if they provide a valid email and password', () =&gt; {
        const mockRefreshPoller = createMockTask();
        const initialState = {
          accessToken: '',
          refreshToken: '',
          userId: '',
        }
        return expectSaga(rootAuthenticationSaga)
          .withReducer(authenticationReducer, initialState)
          .provide([
            // some mock providers set up here
          ])
          // ...more asserts here
          .put(authenticationActions.saveTokens({accessToken: 'VALID_ACCESS_TOKEN', refreshToken: 'VALID_REFRESH_TOKEN'}))
          .hasFinalState({
             accessToken: 'VALID_ACCESS_TOKEN',
             refreshToken: 'VALID_REFRESH_TOKEN',
             userId: 'USER_ID',
          })
          .dispatch(authenticationActions.login.request({email: 'VALID_EMAIL', password: 'VALID_PASSWORD'}))
          .run()
      });
  </code></pre>
  
  <p>In the above test, the <code>select()</code> fails as the correct path (with injection via withReducer) is at <code>state.refreshToken</code> not <code>state.authentication.refreshToken</code></p>
  
  <p>If I inject the state via <code>withState({authentication: {refreshToken, ...}})</code> then the <code>select</code> works as expected, but all the reducer actions happen against the state root, with my final state having the (incorrect) shape:</p>
  
  <pre><code>{state: 
    authentication: {
      refreshToken: '',
      ...
    },
    refreshToken: 'VALID_REFRESH_TOKEN',
    ...
  }
  </code></pre>