refs #13610 Merge branch '13610-projects-hierarchy'
[arvados.git] / src / store / auth / auth-reducer.test.ts
index 3d60c4f400fb1c0fb6ee8f10e4e11a1327d00eb3..17bd42175f8df6647a98d847f6c0a48d79ee4b1d 100644 (file)
@@ -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}`
+        );
+    });
 });