X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6f8e509988756deb7e05a760e718d1ade164fd19..2ba76201944d5ad4ef84aaf16c18f5bbb38a8b89:/src/store/auth/auth-reducer.test.ts diff --git a/src/store/auth/auth-reducer.test.ts b/src/store/auth/auth-reducer.test.ts index c8e2ccb1e9..38cf1581d3 100644 --- a/src/store/auth/auth-reducer.test.ts +++ b/src/store/auth/auth-reducer.test.ts @@ -8,14 +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 progressFn = (id: string, working: boolean) => {}; + const actions: ApiActions = { + progressFn: (id: string, working: boolean) => { }, + errorFn: (id: string, message: string) => { } + }; beforeAll(() => { localStorage.clear(); - reducer = authReducer(createServices(mockConfig({}), progressFn)); + reducer = authReducer(createServices(mockConfig({}), actions)); }); it('should correctly initialise state', () => { @@ -24,13 +28,22 @@ describe('auth-reducer', () => { email: "test@test.com", firstName: "John", lastName: "Doe", - uuid: "uuid", - ownerUuid: "ownerUuid" + uuid: "zzzzz-tpzed-xurymjxw79nv3jz", + ownerUuid: "ownerUuid", + username: "username", + prefs: {}, + isAdmin: false, + isActive: true }; const state = reducer(initialState, authActions.INIT({ user, token: "token" })); expect(state).toEqual({ apiToken: "token", - user + user, + sshKeys: [], + sessions: [], + homeCluster: "zzzzz", + localCluster: "", + remoteHosts: {} }); }); @@ -40,7 +53,12 @@ describe('auth-reducer', () => { const state = reducer(initialState, authActions.SAVE_API_TOKEN("token")); expect(state).toEqual({ apiToken: "token", - user: undefined + user: undefined, + sshKeys: [], + sessions: [], + homeCluster: "", + localCluster: "", + remoteHosts: {}, }); }); @@ -52,18 +70,31 @@ describe('auth-reducer', () => { firstName: "John", lastName: "Doe", uuid: "uuid", - ownerUuid: "ownerUuid" + ownerUuid: "ownerUuid", + username: "username", + prefs: {}, + isAdmin: false, + isActive: true }; const state = reducer(initialState, authActions.USER_DETAILS_SUCCESS(user)); expect(state).toEqual({ apiToken: undefined, + sshKeys: [], + sessions: [], + homeCluster: "", + localCluster: "", + remoteHosts: {}, user: { email: "test@test.com", firstName: "John", lastName: "Doe", uuid: "uuid", ownerUuid: "ownerUuid", + username: "username", + prefs: {}, + isAdmin: false, + isActive: true } }); });