SHARE
TWEET

Untitled

a guest Mar 15th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top