redux-saga-test-plan
redux-saga-test-plan copied to clipboard
Multiples eventChannels
I have this situation, a WebSocket
connection through an eventChannel
and after after a takeEvery
I have two other eventChannel
, with the method provide
I can get the channel
and simulate the emit
, however as I have 3 channels
and I can not specify what each one does.
expectSaga(startWatchingWebsocket)
.withState({ ws: { connId: 'fake-uid' } })
.provide({
take({ channel }, next) {
if (channel) {
return { type: WSTypes.WEBSOCKET_ID, connId: 'fake-uid' };
}
return next();
},
select({ selector }, next) {
if (selector === getConnId) {
return 'fake-uid';
}
return next();
},
})
.put({ type: WSTypes.WEBSOCKET_ID, connId: 'fake-uid' })
.put(AuthActions.authLoading(true))
.dispatch({ type: WSTypes.WS_SUBSCRIBE_LOGIN })
.run();