Guest User

Untitled

a guest
Mar 26th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. .next().take(['LOGOUT', 'LOGIN_FAIL'])
  2.  
  3. const action = yield take(['LOGOUT', 'LOGIN_FAIL']);
  4.  
  5. .next(createMockTask()).take(['LOGOUT', 'LOGIN_FAIL'])
  6.  
  7. it ('authFlow() should work with successful login and then successful logout', () => {
  8. const mockCredentials = {username: 'User', password: 'goodpassword'};
  9. testSaga( stateAuth.watcher )
  10. //this should test the first 'yield', which is waiting for LOGIN or LOGOUT. It works
  11. .next().take(['LOGIN', 'LOGOUT'])
  12.  
  13. // This should test 'authorizeWithRemoteServer', and appears to do that properly
  14. .next({type: 'LOGIN', payload: mockCredentials}).fork( stateAuth.authorizeWithRemoteServer, mockCredentials)
  15.  
  16. // We pass a mock task here
  17. .next(createMockTask()).take(['LOGOUT', 'LOGIN_FAIL'])
  18.  
  19. // And then this should be correct
  20. .next({type: 'LOGOUT'}).cancel(createMockTask())
  21.  
  22. // after which the saga loops back
  23. .take(['LOGIN', 'LOGOUT'])
  24. })
  25.  
  26. it ('authFlow() should work with successful login and then successful logout', () => {
  27. const mockCredentials = {username: 'User', password: 'goodpassword'};
  28. const mockTask = createMockTask();
  29. testSaga( stateAuth.watcher )
  30. //this should test the first 'yield', which is waiting for LOGIN or LOGOUT. It works
  31. .next().take(['LOGIN', 'LOGOUT'])
  32.  
  33. // This should test 'authorizeWithRemoteServer', and appears to do that properly
  34. .next({type: 'LOGIN', payload: mockCredentials}).fork( stateAuth.authorizeWithRemoteServer, mockCredentials)
  35.  
  36. // We pass a mock task here
  37. .next(mockTask).take(['LOGOUT', 'LOGIN_FAIL'])
  38.  
  39. // And then this should be correct
  40. .next({type: 'LOGOUT'}).cancel(mockTask)
  41.  
  42. // after which the saga loops back
  43. .take(['LOGIN', 'LOGOUT'])
  44. })
Add Comment
Please, Sign In to add comment