X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e13e7dd672160e4ab5569c24133f4f6032db4a9a..d4f479b1c2bd4bb67d5e69f792b503f375d6dfc9:/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 8eeb7c3c63..f527edec21 100644 --- a/src/store/auth/auth-reducer.test.ts +++ b/src/store/auth/auth-reducer.test.ts @@ -7,13 +7,19 @@ 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({ apiHost: "/arvados/v1", keepWebHost: "" })); + reducer = authReducer(createServices(mockConfig({}), actions)); }); it('should correctly initialise state', () => { @@ -23,12 +29,17 @@ describe('auth-reducer', () => { firstName: "John", lastName: "Doe", uuid: "uuid", - ownerUuid: "ownerUuid" + ownerUuid: "ownerUuid", + username: "username", + prefs: {}, + isAdmin: false }; const state = reducer(initialState, authActions.INIT({ user, token: "token" })); expect(state).toEqual({ apiToken: "token", - user + user, + sshKeys: [], + sessions: [] }); }); @@ -38,7 +49,9 @@ describe('auth-reducer', () => { const state = reducer(initialState, authActions.SAVE_API_TOKEN("token")); expect(state).toEqual({ apiToken: "token", - user: undefined + user: undefined, + sshKeys: [], + sessions: [] }); }); @@ -50,18 +63,26 @@ describe('auth-reducer', () => { firstName: "John", lastName: "Doe", uuid: "uuid", - ownerUuid: "ownerUuid" + ownerUuid: "ownerUuid", + username: "username", + prefs: {}, + isAdmin: false }; const state = reducer(initialState, authActions.USER_DETAILS_SUCCESS(user)); expect(state).toEqual({ apiToken: undefined, + sshKeys: [], + sessions: [], user: { email: "test@test.com", firstName: "John", lastName: "Doe", uuid: "uuid", ownerUuid: "ownerUuid", + username: "username", + prefs: {}, + isAdmin: false } }); });