redux-saga-test-plan icon indicating copy to clipboard operation
redux-saga-test-plan copied to clipboard

Yielding a call that has an await inside of the function

Open birdwell opened this issue 4 years ago • 0 comments

It gets stuck on the Client.history(channel) and doesn't continue in the generator function to the final line.

Saga

export const loadChat = async channel => {
  if (channel) {
    await Client.history(channel);
  }
};
function* setChannels(action: ReturnType<typeof setChannelsAction>) {
  const { channels } = action.payload;
  yield call(
    loadChat,
    channels.find(...)
  );
  yield put(setChannelGroupsAction(channelGroups));
}

Test

    return expectSaga(setChannelsSaga, setChannels({ channels, channelGroups }))
      .withState(defaultState)
      .call(loadChat, channels[2])
      .put(setChannelGroupsAction(channelGroups))
      .run();

birdwell avatar Aug 24 '20 21:08 birdwell