left-side-panel-small-refactor
[arvados-workbench2.git] / src / store / side-panel / side-panel-reducer.test.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import sidePanelReducer from "./side-panel-reducer";
6 import actions from "./side-panel-action";
7
8 describe('side-panel-reducer', () => {
9
10     it('should toggle activity on side-panel', () => {
11         const initialState = [
12             {
13                 id: "1",
14                 name: "Projects",
15                 icon: "fas fa-th fa-fw",
16                 open: false,
17                 active: false,
18             }
19         ];
20         const project = [
21             {
22                 id: "1",
23                 name: "Projects",
24                 icon: "fas fa-th fa-fw",
25                 open: false,
26                 active: true,
27             }
28         ];
29
30         const state = sidePanelReducer(initialState, actions.TOGGLE_SIDE_PANEL_ITEM_ACTIVE(initialState[0].id));
31         expect(state).toEqual(project);
32     });
33
34     it('should open side-panel item', () => {
35         const initialState = [
36             {
37                 id: "1",
38                 name: "Projects",
39                 icon: "fas fa-th fa-fw",
40                 open: false,
41                 active: false,
42             }
43         ];
44         const project = [
45             {
46                 id: "1",
47                 name: "Projects",
48                 icon: "fas fa-th fa-fw",
49                 open: true,
50                 active: false,
51             }
52         ];
53
54         const state = sidePanelReducer(initialState, actions.TOGGLE_SIDE_PANEL_ITEM_OPEN(initialState[0].id));
55         expect(state).toEqual(project);
56     });
57
58     it('should remove activity on side-panel item', () => {
59         const initialState = [
60             {
61                 id: "1",
62                 name: "Projects",
63                 icon: "fas fa-th fa-fw",
64                 open: false,
65                 active: true,
66             }
67         ];
68         const project = [
69             {
70                 id: "1",
71                 name: "Projects",
72                 icon: "fas fa-th fa-fw",
73                 open: false,
74                 active: false,
75             }
76         ];
77
78         const state = sidePanelReducer(initialState, actions.RESET_SIDE_PANEL_ACTIVITY(initialState[0].id));
79         expect(state).toEqual(project);
80     });
81 });