Unit testing redux-saga task cancellation -


i wondering if had tips on how unit-test following redux-saga login/logout flow:

let pollingtask = null  function * handlelogin () {   try {     const token = yield call(loginhandler)     pollingtask = yield fork(handlepolls, token)     yield put('login_succses')   } catch (e) {     yield put('login_failure')   } }  function * handlepolls (token) {   while (true) {     try {       yield call(pollhandler, token)       yield put('poll_success')     } catch (e) {       yield put('poll_failure')     } {       if (yield cancelled()) {         yield call(pollcancelled)       }     }   } }  function * handlelogout () {   try {     yield call(logouthandler)     yield cancel(pollingtask)      yield put('logout_success')   } catch (e) {     yield put('logout_failure')   } } 

since need cancel pollingtask on logout, tried using createmocktask() in tests value undefined when invoke handlelogout() saga, although know handlelogin() started first , initialize pollingtask.

any appreciated!


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -