Merge branch '13601-basic-data-exploring-component'
[arvados-workbench2.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             kind: ""
19         };
20
21         const state = projectsReducer(initialState, actions.CREATE_PROJECT(project));
22         expect(state).toEqual([project]);
23     });
24
25     it('should load projects', () => {
26         const initialState = undefined;
27         const project = {
28             name: 'test',
29             href: 'href',
30             createdAt: '2018-01-01',
31             modifiedAt: '2018-01-01',
32             ownerUuid: 'owner-test123',
33             uuid: 'test123',
34             kind: ""
35         };
36
37         const projects = [project, project];
38         const state = projectsReducer(initialState, actions.PROJECTS_SUCCESS({projects, parentItemId: undefined}));
39         expect(state).toEqual([{
40                 active: false,
41                 open: false,
42                 id: "test123",
43                 items: [],
44                 data: project,
45                 status: 0
46             }, {
47                 active: false,
48                 open: false,
49                 id: "test123",
50                 items: [],
51                 data: project,
52                 status: 0
53             }
54         ]);
55     });
56 });