From 13276b8d6a861c4a55faa5d690c157890333435c Mon Sep 17 00:00:00 2001 From: tomivm Date: Thu, 4 Aug 2022 17:14:16 -0300 Subject: [PATCH 1/2] localize user during logout --- src/components/Account/Login/Login.actions.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 }; From d9912d8ea36b24182c8ac3a3c796fca2ff3d4467 Mon Sep 17 00:00:00 2001 From: tomivm Date: Thu, 4 Aug 2022 18:01:48 -0300 Subject: [PATCH 2/2] refactor logout test --- src/components/Account/Login/Login.actions.test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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);