import { changePasswordWorker } from '../changePassword' ; import { changePassword } from 'modules/account/actions' ; import { put } from 'redux-saga/effects' ; import { navTypes } from '../../../constants' ; import * as navigator from 'modules/navigator' ; describe ( 'changePasswordWorker' , ( ) => { const action = { type : changePassword . started , payload : { ecosystemId : '1' , encKey : 'encKey' , address : 'address' , } } ; it ( 'changePasswordWorker cancel' , ( ) => { const iterator = changePasswordWorker ( action ) ; iterator . next ( ) ; iterator . next ( ) ; expect ( iterator . next ( { cancel : { } } ) . value ) . toEqual ( undefined ) ; } ) ; it ( 'changePasswordWorker confirm, invalid password' , ( ) => { const iterator = changePasswordWorker ( action ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( { confirm : { payload : 'password' } } ) ; expect ( iterator . next ( '' ) . value ) . toEqual ( undefined ) ; } ) ; it ( 'changePasswordWorker confirm, valid password, cancelChangingPassword' , ( ) => { const iterator = changePasswordWorker ( action ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( { confirm : { payload : 'password' } } ) ; iterator . next ( '12323' ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( { failure : { } } ) ; expect ( iterator . next ( ) . value ) . toEqual ( undefined ) ; } ) ; it ( 'changePasswordWorker confirm, valid password, confirmChangingPassword, changing password for current account' , ( ) => { const iterator = changePasswordWorker ( action ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( { confirm : { payload : 'password' } } ) ; iterator . next ( '12323' ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( { success : { payload : 'newPassword' } } ) ; iterator . next ( ) ; iterator . next ( ) ; expect ( iterator . next ( 'address' ) . value ) . toEqual ( put ( navigator . actions . navigateWithReset ( [ { routeName : navTypes . HOME } ] ) ) ) ; } ) ; it ( 'changePasswordWorker confirm, valid password, confirmChangingPassword, changing password for current account' , ( ) => { const iterator = changePasswordWorker ( action ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( { confirm : { payload : 'password' } } ) ; iterator . next ( '12323' ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( ) ; iterator . next ( { success : { payload : 'newPassword' } } ) ; iterator . next ( ) ; iterator . next ( ) ; expect ( iterator . next ( '123' ) . value ) . toEqual ( put ( navigator . actions . navigateWithReset ( [ { routeName : navTypes . SIGN_IN , params : { ecosystemId : action . payload . ecosystemId , password : 'password' , id : 'address' , } } ] ) ) ) ; } ) ; } ) ;