redux-saga-test-plan
redux-saga-test-plan copied to clipboard
Yielding a call that has an await inside of the function
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();