How to test a saga function by mocking a generating function?

Asked

Viewed 38 times

0

So far I haven’t found an efficient way to test the sagas of my "start" function with the redux-saga-test-plan along with Jest. I already tried to fuck the function fluxo, but I did not succeed. My intention is to test only the function iniciar, since, in my opinion it is impracticable to test the sagas of the function fluxo while testing those of iniciar. Can someone help me solve this problem?

export function* fluxo(action) {
  yield put({type:'REALIZAR_ACAO_UM'})
  yield put({type:'REALIZAR_ACAO_DOIS'})
}

export function* iniciar(action) {
  yield put({type:'INICIANDO_FLUXO'})
  const {data} = yield call(api.get)
  yield call(fluxo,data)
  yield put({type:'SUCCESS'})   
}

export default function* watcher() {
  yield takeLatest('FLUXO', fluxo);
  yield takeLatest('INICIAR', iniciar);
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.