Merge branch 'master' into 14452-my-account
[arvados-workbench2.git] / src / store / auth / auth-reducer.test.ts
index 2b1920a61db9fc47e32fb543341a2010ccd59d63..b9f768f1cb0a42a9653d119cc577e516b21407ba 100644 (file)
@@ -8,13 +8,18 @@ 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";
 
 describe('auth-reducer', () => {
     let reducer: (state: AuthState | undefined, action: AuthAction) => any;
+    const actions: ApiActions = {
+        progressFn: (id: string, working: boolean) => {},
+        errorFn: (id: string, message: string) => {}
+    };
 
     beforeAll(() => {
         localStorage.clear();
-        reducer = authReducer(createServices(mockConfig({})));
+        reducer = authReducer(createServices(mockConfig({}), actions));
     });
 
     it('should correctly initialise state', () => {
@@ -24,12 +29,16 @@ describe('auth-reducer', () => {
             firstName: "John",
             lastName: "Doe",
             uuid: "uuid",
-            ownerUuid: "ownerUuid"
+            ownerUuid: "ownerUuid",
+            identityUrl: "identityUrl",
+            prefs: {},
+            isAdmin: false
         };
         const state = reducer(initialState, authActions.INIT({ user, token: "token" }));
         expect(state).toEqual({
             apiToken: "token",
-            user
+            user,
+            sshKeys: []
         });
     });
 
@@ -39,7 +48,8 @@ describe('auth-reducer', () => {
         const state = reducer(initialState, authActions.SAVE_API_TOKEN("token"));
         expect(state).toEqual({
             apiToken: "token",
-            user: undefined
+            user: undefined,
+            sshKeys: []
         });
     });
 
@@ -51,18 +61,23 @@ describe('auth-reducer', () => {
             firstName: "John",
             lastName: "Doe",
             uuid: "uuid",
-            ownerUuid: "ownerUuid"
+            ownerUuid: "ownerUuid",
+            identityUrl: "identityUrl",
+            prefs: {},
+            isAdmin: false
         };
 
         const state = reducer(initialState, authActions.USER_DETAILS_SUCCESS(user));
         expect(state).toEqual({
             apiToken: undefined,
+            sshKeys: [],
             user: {
                 email: "test@test.com",
                 firstName: "John",
                 lastName: "Doe",
                 uuid: "uuid",
                 ownerUuid: "ownerUuid",
+                isAdmin: false
             }
         });
     });