Skip to content

Commit

Permalink
Merge pull request #1251 from tomivm/feature/localize-user-on-logout
Browse files Browse the repository at this point in the history
Feature/localize user on logout
  • Loading branch information
martinbedouret authored Aug 10, 2022
2 parents 25fac7a + d9912d8 commit 1e2aa16
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/components/Account/Login/Login.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
};
Expand Down
7 changes: 5 additions & 2 deletions src/components/Account/Login/Login.actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1e2aa16

Please sign in to comment.