[ARVADOS-WORKBENCH2] updated: a8dd91ed05edf80ac654770eef5ba66142376d8d
Git user
git at public.curoverse.com
Wed Jun 6 15:05:36 EDT 2018
Summary of changes:
src/services/auth-service/auth-service.ts | 4 ++--
src/store/auth/auth-reducer.test.ts | 28 ++++++----------------------
yarn.lock | 2 +-
3 files changed, 9 insertions(+), 25 deletions(-)
via a8dd91ed05edf80ac654770eef5ba66142376d8d (commit)
from 5320327aa99710bb1cd1ce090fcb8e2b1d6de0da (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit a8dd91ed05edf80ac654770eef5ba66142376d8d
Author: Daniel Kos <daniel.kos at contractors.roche.com>
Date: Wed Jun 6 21:05:34 2018 +0200
Make login/logout tests compatible with jsdom
Feature #13563
Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos at contractors.roche.com>:
diff --git a/src/services/auth-service/auth-service.ts b/src/services/auth-service/auth-service.ts
index 9e75c72..4b213fb 100644
--- a/src/services/auth-service/auth-service.ts
+++ b/src/services/auth-service/auth-service.ts
@@ -47,11 +47,11 @@ export default class AuthService {
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}`;
- window.location.href = `${API_HOST}/logout?return_to=${currentUrl}`;
+ window.location.assign(`${API_HOST}/logout?return_to=${currentUrl}`);
}
}
diff --git a/src/store/auth/auth-reducer.test.ts b/src/store/auth/auth-reducer.test.ts
index 9290f57..f2e20ba 100644
--- a/src/store/auth/auth-reducer.test.ts
+++ b/src/store/auth/auth-reducer.test.ts
@@ -12,7 +12,7 @@ import {
} 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(() => {
@@ -84,34 +84,18 @@ describe('auth-reducer', () => {
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());
- 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;
-
- const location = {
- href: 'http://localhost:3000',
- protocol: 'http:',
- host: 'localhost:3000'
- };
-
- global['window'] = { location };
-
+ window.location.assign = jest.fn();
authReducer(initialState, actions.LOGOUT());
- expect(window.location.href).toBe(
+ expect(window.location.assign).toBeCalledWith(
`${API_HOST}/logout?return_to=${location.protocol}//${location.host}`
);
});
diff --git a/yarn.lock b/yarn.lock
index 17549e0..7b9820b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4003,7 +4003,7 @@ jest-leak-detector@^22.4.0:
dependencies:
pretty-format "^22.4.3"
-jest-localstorage-mock@^2.2.0:
+jest-localstorage-mock at 2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/jest-localstorage-mock/-/jest-localstorage-mock-2.2.0.tgz#ce9a9de01dfdde2ad8aa08adf73acc7e5cc394cf"
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list