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

Multiples eventChannels

Open HigoRibeiro opened this issue 5 years ago • 0 comments

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();

HigoRibeiro avatar May 08 '19 20:05 HigoRibeiro