Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .next().take(['LOGOUT', 'LOGIN_FAIL'])
- const action = yield take(['LOGOUT', 'LOGIN_FAIL']);
- .next(createMockTask()).take(['LOGOUT', 'LOGIN_FAIL'])
- it ('authFlow() should work with successful login and then successful logout', () => {
- const mockCredentials = {username: 'User', password: 'goodpassword'};
- testSaga( stateAuth.watcher )
- //this should test the first 'yield', which is waiting for LOGIN or LOGOUT. It works
- .next().take(['LOGIN', 'LOGOUT'])
- // This should test 'authorizeWithRemoteServer', and appears to do that properly
- .next({type: 'LOGIN', payload: mockCredentials}).fork( stateAuth.authorizeWithRemoteServer, mockCredentials)
- // We pass a mock task here
- .next(createMockTask()).take(['LOGOUT', 'LOGIN_FAIL'])
- // And then this should be correct
- .next({type: 'LOGOUT'}).cancel(createMockTask())
- // after which the saga loops back
- .take(['LOGIN', 'LOGOUT'])
- })
- it ('authFlow() should work with successful login and then successful logout', () => {
- const mockCredentials = {username: 'User', password: 'goodpassword'};
- const mockTask = createMockTask();
- testSaga( stateAuth.watcher )
- //this should test the first 'yield', which is waiting for LOGIN or LOGOUT. It works
- .next().take(['LOGIN', 'LOGOUT'])
- // This should test 'authorizeWithRemoteServer', and appears to do that properly
- .next({type: 'LOGIN', payload: mockCredentials}).fork( stateAuth.authorizeWithRemoteServer, mockCredentials)
- // We pass a mock task here
- .next(mockTask).take(['LOGOUT', 'LOGIN_FAIL'])
- // And then this should be correct
- .next({type: 'LOGOUT'}).cancel(mockTask)
- // after which the saga loops back
- .take(['LOGIN', 'LOGOUT'])
- })
Add Comment
Please, Sign In to add comment