Advertisement
Guest User

Untitled

a guest
Mar 15th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. export const startLogout = () => {
  2. return ( dispatch ) => {
  3.  
  4. return firebase
  5. .auth()
  6. .signOut()
  7. .then(() => {
  8. dispatch( logout() );
  9. history.push( '/login' );
  10. })
  11. .catch( ( err ) => {
  12. // Simple redirect to non existent route
  13. history.push( '/oops' );
  14. console.log( err );
  15. });
  16. };
  17.  
  18. test( 'should start logout', ( done ) => {
  19. const store = createMockStore({});
  20.  
  21. store.dispatch( startLogout() ).then(() => {
  22. const actions = store.getActions();
  23.  
  24. expect( actions[0] ).toEqual({
  25. type: LOGOUT
  26. });
  27.  
  28. const history = { push: jest.fn() };
  29. expect( history.push ).toHaveBeenLastCalledWith( '/login' );
  30.  
  31. done();
  32. }).catch((err) => {
  33. console.log( err );
  34. done();
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement