Unit testing Redux:如何对调度另一个异步操作的异步操作进行单元测试

Unit testing Redux:如何对调度另一个异步操作的异步操作进行单元测试,unit-testing,asynchronous,ecmascript-6,action,redux,Unit Testing,Asynchronous,Ecmascript 6,Action,Redux,我很难测试一个分派另一个异步函数的异步函数: export function validateVerifyCode(payload, pin) { return dispatch => { dispatch(requesting()); return fetch(`${BASE_URL}/register`).then(resp => { return resp.json() }) .then(json => {

我很难测试一个分派另一个异步函数的异步函数:

export function validateVerifyCode(payload, pin) {
  return dispatch => {
    dispatch(requesting());
    return fetch(`${BASE_URL}/register`).then(resp => {
        return resp.json()
      })
      .then(json => {
        dispatch(hasSubscriptionCheck(json));
        }
      })
      .catch(error => dispatch(hasError(error)))
  }
}

function hasSubscriptionCheck(payload) {
  return dispatch => {
    dispatch(requesting());
    return fetch(`${BASE_URL}/subscriptions`)
      .then(resp => resp.json())
      .then(json => {
        if (json.length == 0) {
          dispatch(handleStripeSubmit(payload));
        }
      })
      .catch(error => dispatch(hasError(error)));
  }
}
问题是在我的单元测试中,它实际上没有调用HassSubscriptionCheck:

  it('validates the verify code', (done) => {
    const stub = sinon.stub(Stripe.card, 'createToken');
    stub.onCall(0).returns(new Promise((resolve) => {
      resolve({});
    }));


    nock(BASE_URL)
      .defaultReplyHeaders({
        'Content-Type': 'application/json',
        'Authentication': token
      })
      .post('/register')
      .reply(200, {id: 'userid1234'})
      .get('/^subscriptions')
      .reply(200, []);


    const store = mockStore({});

    const payload = {
...
    };

    store.dispatch(actions.validateVerifyCode(payload, '123456'))
      .then(() => {
        console.log(store.getActions());
      })
      .then(done)
      .catch(done);
  })
但奇怪的是,当我运行console.log store.getActions()时,我看到了两个动作:

[ { type: 'REQUESTING' }, { type: 'REQUESTING' } ]

我如何告诉测试框架调用第二次获取?

不清楚什么是
mockStore
,请澄清您使用的是哪个包好吗?@DanAbramov mockStore来自。我从async action creators中获取的原始示例