X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/49102c744e277370da62c279d25563d633295cc2..3ad7e33a2d50e9ed2298624ea5cac7cb5cd21a6f:/src/store/auth/auth-reducer.test.ts diff --git a/src/store/auth/auth-reducer.test.ts b/src/store/auth/auth-reducer.test.ts index 3d60c4f400..17bd42175f 100644 --- a/src/store/auth/auth-reducer.test.ts +++ b/src/store/auth/auth-reducer.test.ts @@ -10,8 +10,9 @@ import { USER_FIRST_NAME_KEY, USER_LAST_NAME_KEY } from "../../services/auth-service/auth-service"; +import { API_HOST } from "../../common/api/server-api"; -require('jest-localstorage-mock'); +import 'jest-localstorage-mock'; describe('auth-reducer', () => { beforeAll(() => { @@ -80,4 +81,22 @@ describe('auth-reducer', () => { expect(localStorage.getItem(API_TOKEN_KEY)).toBe("token"); }); + + it('should fire external url to login', () => { + const initialState = undefined; + window.location.assign = jest.fn(); + authReducer(initialState, actions.LOGIN()); + expect(window.location.assign).toBeCalledWith( + `${API_HOST}/login?return_to=${window.location.protocol}//${window.location.host}/token` + ); + }); + + it('should fire external url to logout', () => { + const initialState = undefined; + window.location.assign = jest.fn(); + authReducer(initialState, actions.LOGOUT()); + expect(window.location.assign).toBeCalledWith( + `${API_HOST}/logout?return_to=${location.protocol}//${location.host}` + ); + }); });