1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { linkAccountPanelReducer, LinkAccountPanelError, LinkAccountPanelStatus, OriginatingUser } from "store/link-account-panel/link-account-panel-reducer";
6 import { linkAccountPanelActions } from "store/link-account-panel/link-account-panel-actions";
8 describe('link-account-panel-reducer', () => {
9 const initialState = undefined;
11 it('handles initial link account state', () => {
12 const targetUser = { } as any;
13 targetUser.username = "targetUser";
15 const state = linkAccountPanelReducer(initialState, linkAccountPanelActions.LINK_INIT({targetUser}));
16 expect(state).toEqual({
19 selectedCluster: undefined,
20 targetUserToken: undefined,
21 userToLink: undefined,
22 userToLinkToken: undefined,
23 originatingUser: OriginatingUser.NONE,
24 error: LinkAccountPanelError.NONE,
25 status: LinkAccountPanelStatus.INITIAL
29 it('handles loaded link account state', () => {
30 const targetUser = { } as any;
31 targetUser.username = "targetUser";
32 const targetUserToken = "targettoken";
34 const userToLink = { } as any;
35 userToLink.username = "userToLink";
36 const userToLinkToken = "usertoken";
38 const originatingUser = OriginatingUser.TARGET_USER;
40 const state = linkAccountPanelReducer(initialState, linkAccountPanelActions.LINK_LOAD({
41 originatingUser, targetUser, targetUserToken, userToLink, userToLinkToken}));
42 expect(state).toEqual({
46 selectedCluster: undefined,
49 originatingUser: OriginatingUser.TARGET_USER,
50 error: LinkAccountPanelError.NONE,
51 status: LinkAccountPanelStatus.LINKING
55 it('handles loaded invalid account state', () => {
56 const targetUser = { } as any;
57 targetUser.username = "targetUser";
59 const userToLink = { } as any;
60 userToLink.username = "userToLink";
62 const originatingUser = OriginatingUser.TARGET_USER;
63 const error = LinkAccountPanelError.NON_ADMIN;
65 const state = linkAccountPanelReducer(initialState, linkAccountPanelActions.LINK_INVALID({targetUser, userToLink, originatingUser, error}));
66 expect(state).toEqual({
68 targetUserToken: undefined,
70 selectedCluster: undefined,
72 userToLinkToken: undefined,
73 originatingUser: OriginatingUser.TARGET_USER,
74 error: LinkAccountPanelError.NON_ADMIN,
75 status: LinkAccountPanelStatus.ERROR