X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/dd89200ad6fdbfa337fdbab5f54def8712c6746c..cc72c29b709759a4498ad232e3f0374e857c7a62:/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 bc9d34ee0a..a4017db3be 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("/arvados/v1")); + reducer = authReducer(createServices(mockConfig({}), actions)); }); it('should correctly initialise state', () => { @@ -23,12 +29,14 @@ describe('auth-reducer', () => { firstName: "John", lastName: "Doe", uuid: "uuid", - ownerUuid: "ownerUuid" + ownerUuid: "ownerUuid", + isAdmin: false }; - const state = reducer(initialState, authActions.INIT({user, token: "token"})); + const state = reducer(initialState, authActions.INIT({ user, token: "token" })); expect(state).toEqual({ apiToken: "token", - user + user, + sshKeys: [] }); }); @@ -38,7 +46,8 @@ describe('auth-reducer', () => { const state = reducer(initialState, authActions.SAVE_API_TOKEN("token")); expect(state).toEqual({ apiToken: "token", - user: undefined + user: undefined, + sshKeys: [] }); }); @@ -50,18 +59,21 @@ describe('auth-reducer', () => { firstName: "John", lastName: "Doe", uuid: "uuid", - ownerUuid: "ownerUuid" + ownerUuid: "ownerUuid", + 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 } }); });