19302: tree nav to virtual machines works Arvados-DCO-1.1-Signed-off-by: Lisa Knox...
[arvados-workbench2.git] / src / store / auth / auth-reducer.test.ts
index 773f9f82dbd737b2e7f0d3fa843b5be4779d6d57..6a1fb87faa8c10d8fc30a47bc3005c3ead1a3df0 100644 (file)
@@ -6,15 +6,15 @@ import { authReducer, AuthState } from "./auth-reducer";
 import { AuthAction, authActions } from "./auth-action";
 
 import 'jest-localstorage-mock';
-import { createServices } from "~/services/services";
-import { mockConfig } from '~/common/config';
-import { ApiActions } from "~/services/api/api-actions";
+import { createServices } from "services/services";
+import { mockConfig } from 'common/config';
+import { ApiActions } from "services/api/api-actions";
 
 describe('auth-reducer', () => {
     let reducer: (state: AuthState | undefined, action: AuthAction) => any;
     const actions: ApiActions = {
-        progressFn: (id: string, working: boolean) => {},
-        errorFn: (id: string, message: string) => {}
+        progressFn: (id: string, working: boolean) => { },
+        errorFn: (id: string, message: string) => { }
     };
 
     beforeAll(() => {
@@ -28,30 +28,25 @@ describe('auth-reducer', () => {
             email: "test@test.com",
             firstName: "John",
             lastName: "Doe",
-            uuid: "uuid",
+            uuid: "zzzzz-tpzed-xurymjxw79nv3jz",
             ownerUuid: "ownerUuid",
-            identityUrl: "identityUrl",
+            username: "username",
             prefs: {},
-            isAdmin: false
+            isAdmin: false,
+            isActive: true
         };
-        const state = reducer(initialState, authActions.INIT({ user, token: "token" }));
+        const state = reducer(initialState, authActions.INIT_USER({ user, token: "token" }));
         expect(state).toEqual({
             apiToken: "token",
+            config: mockConfig({}),
             user,
             sshKeys: [],
-            sessions: []
-        });
-    });
-
-    it('should save api token', () => {
-        const initialState = undefined;
-
-        const state = reducer(initialState, authActions.SAVE_API_TOKEN("token"));
-        expect(state).toEqual({
-            apiToken: "token",
-            user: undefined,
-            sshKeys: [],
-            sessions: []
+            sessions: [],
+            homeCluster: "zzzzz",
+            localCluster: "",
+            loginCluster: "",
+            remoteHosts: {},
+            remoteHostsConfig: {}
         });
     });
 
@@ -64,25 +59,33 @@ describe('auth-reducer', () => {
             lastName: "Doe",
             uuid: "uuid",
             ownerUuid: "ownerUuid",
-            identityUrl: "identityUrl",
+            username: "username",
             prefs: {},
-            isAdmin: false
+            isAdmin: false,
+            isActive: true
         };
 
         const state = reducer(initialState, authActions.USER_DETAILS_SUCCESS(user));
         expect(state).toEqual({
             apiToken: undefined,
+            config: mockConfig({}),
             sshKeys: [],
             sessions: [],
+            homeCluster: "uuid",
+            localCluster: "",
+            loginCluster: "",
+            remoteHosts: {},
+            remoteHostsConfig: {},
             user: {
                 email: "test@test.com",
                 firstName: "John",
                 lastName: "Doe",
                 uuid: "uuid",
                 ownerUuid: "ownerUuid",
-                identityUrl: "identityUrl",
+                username: "username",
                 prefs: {},
-                isAdmin: false
+                isAdmin: false,
+                isActive: true
             }
         });
     });