Feature #13563
Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos@contractors.roche.com>:
public login() {
const currentUrl = `${window.location.protocol}//${window.location.host}/token`;
public login() {
const currentUrl = `${window.location.protocol}//${window.location.host}/token`;
- window.location.href = `${API_HOST}/login?return_to=${currentUrl}`;
+ window.location.assign(`${API_HOST}/login?return_to=${currentUrl}`);
}
public logout() {
const currentUrl = `${window.location.protocol}//${window.location.host}`;
}
public logout() {
const currentUrl = `${window.location.protocol}//${window.location.host}`;
- window.location.href = `${API_HOST}/logout?return_to=${currentUrl}`;
+ window.location.assign(`${API_HOST}/logout?return_to=${currentUrl}`);
} from "../../services/auth-service/auth-service";
import { API_HOST } from "../../common/server-api";
} from "../../services/auth-service/auth-service";
import { API_HOST } from "../../common/server-api";
-require('jest-localstorage-mock');
+import 'jest-localstorage-mock';
describe('auth-reducer', () => {
beforeAll(() => {
describe('auth-reducer', () => {
beforeAll(() => {
it('should fire external url to login', () => {
const initialState = undefined;
it('should fire external url to login', () => {
const initialState = undefined;
-
- const location = {
- href: 'http://localhost:3000',
- protocol: 'http:',
- host: 'localhost:3000'
- };
-
- global['window'] = { location };
-
+ window.location.assign = jest.fn();
authReducer(initialState, actions.LOGIN());
authReducer(initialState, actions.LOGIN());
- expect(window.location.href).toBe(
- `${API_HOST}/login?return_to=${location.protocol}//${location.host}/token`
+ 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;
);
});
it('should fire external url to logout', () => {
const initialState = undefined;
-
- const location = {
- href: 'http://localhost:3000',
- protocol: 'http:',
- host: 'localhost:3000'
- };
-
- global['window'] = { location };
-
+ window.location.assign = jest.fn();
authReducer(initialState, actions.LOGOUT());
authReducer(initialState, actions.LOGOUT());
- expect(window.location.href).toBe(
+ expect(window.location.assign).toBeCalledWith(
`${API_HOST}/logout?return_to=${location.protocol}//${location.host}`
);
});
`${API_HOST}/logout?return_to=${location.protocol}//${location.host}`
);
});
dependencies:
pretty-format "^22.4.3"
dependencies:
pretty-format "^22.4.3"
-jest-localstorage-mock@^2.2.0:
+jest-localstorage-mock@2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/jest-localstorage-mock/-/jest-localstorage-mock-2.2.0.tgz#ce9a9de01dfdde2ad8aa08adf73acc7e5cc394cf"
version "2.2.0"
resolved "https://registry.yarnpkg.com/jest-localstorage-mock/-/jest-localstorage-mock-2.2.0.tgz#ce9a9de01dfdde2ad8aa08adf73acc7e5cc394cf"