refs #13622 Merge branch '13622-children-in-root-tree'
[arvados.git] / src / store / project / project-reducer.test.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import projectsReducer from "./project-reducer";
6 import actions from "./project-action";
7
8 describe('project-reducer', () => {
9     it('should add new project to the list', () => {
10         const initialState = undefined;
11         const project = {
12             name: 'test',
13             href: 'href',
14             createdAt: '2018-01-01',
15             modifiedAt: '2018-01-01',
16             ownerUuid: 'owner-test123',
17             uuid: 'test123'
18         };
19
20         const state = projectsReducer(initialState, actions.CREATE_PROJECT(project));
21         expect(state).toEqual([project]);
22     });
23
24     it('should load projects', () => {
25         const initialState = undefined;
26         const project = {
27             name: 'test',
28             href: 'href',
29             createdAt: '2018-01-01',
30             modifiedAt: '2018-01-01',
31             ownerUuid: 'owner-test123',
32             uuid: 'test123'
33         };
34
35         const projects = [project, project];
36         const state = projectsReducer(initialState, actions.PROJECTS_SUCCESS({projects, parentItemId: undefined}));
37         expect(state).toEqual([{
38                 active: false,
39                 open: false,
40                 id: "test123",
41                 items: [],
42                 data: project
43             }, {
44                 active: false,
45                 open: false,
46                 id: "test123",
47                 items: [],
48                 data: project
49             }
50         ]);
51     });
52 });