diff --git a/src/components/Account/Login/Login.actions.js b/src/components/Account/Login/Login.actions.js index 249abe48a..9ce5ebea1 100644 --- a/src/components/Account/Login/Login.actions.js +++ b/src/components/Account/Login/Login.actions.js @@ -6,7 +6,11 @@ import { changePitch, changeRate } from '../../../providers/SpeechProvider/SpeechProvider.actions'; -import { disableTour } from '../../App/App.actions'; +import { + disableTour, + setUnloggedUserLocation, + updateUnloggedUserLocation +} from '../../App/App.actions'; import { getVoiceURI } from '../../../i18n'; export function loginSuccess(payload) { @@ -17,6 +21,14 @@ export function loginSuccess(payload) { } export function logout() { + return async dispatch => { + dispatch(setUnloggedUserLocation(null)); + dispatch(updateUnloggedUserLocation()); + dispatch(logoutSuccess()); + }; +} + +function logoutSuccess() { return { type: LOGOUT }; diff --git a/src/components/Account/Login/Login.actions.test.js b/src/components/Account/Login/Login.actions.test.js index 6dd2c7f70..5dce681ad 100644 --- a/src/components/Account/Login/Login.actions.test.js +++ b/src/components/Account/Login/Login.actions.test.js @@ -101,11 +101,14 @@ describe('actions', () => { }; expect(actions.loginSuccess(userData)).toEqual(expectedAction); }); - it('should create an action to logout', () => { + it('should create an action to logout', async () => { + const store = mockStore(initialState); const expectedAction = { type: LOGOUT }; - expect(actions.logout()).toEqual(expectedAction); + await store.dispatch(actions.logout()); + const logoutActions = store.getActions(); + expect(logoutActions).toContainEqual(expectedAction); }); it('should create an action to login', () => { const store = mockStore(initialState);