1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { authReducer } from "./auth-reducer";
6 import { authActions } from "./auth-action";
7 import { createServices } from "services/services";
8 import { mockConfig } from 'common/config';
10 describe('auth-reducer', () => {
13 progressFn: (id, working) => { },
14 errorFn: (id, message) => { }
19 reducer = authReducer(createServices(mockConfig({}), actions));
22 it('should correctly initialise state', () => {
23 const initialState = undefined;
25 email: "test@test.com",
28 uuid: "zzzzz-tpzed-xurymjxw79nv3jz",
29 ownerUuid: "ownerUuid",
37 const state = reducer(initialState, authActions.INIT_USER({ user, token: "token" }));
38 expect(state).to.deep.equal({
40 apiTokenExpiration: undefined,
41 apiTokenLocation: undefined,
42 config: mockConfig({}),
46 extraApiToken: undefined,
47 extraApiTokenExpiration: undefined,
56 it('should set user details on success fetch', () => {
57 const initialState = undefined;
60 email: "test@test.com",
64 ownerUuid: "ownerUuid",
73 const state = reducer(initialState, authActions.USER_DETAILS_SUCCESS(user));
74 expect(state).to.deep.equal({
76 apiTokenExpiration: undefined,
77 apiTokenLocation: undefined,
78 config: mockConfig({}),
81 extraApiToken: undefined,
82 extraApiTokenExpiration: undefined,
87 remoteHostsConfig: {},
89 email: "test@test.com",
93 ownerUuid: "ownerUuid",