7b57ba7264430e50c9ec29a527f780157ccea2ce
[arvados-workbench2.git] / src / store / collection / collection-reducer.test.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import collectionsReducer from "./collection-reducer";
6 import actions from "./collection-action";
7
8 describe('collection-reducer', () => {
9     it('should add new collection to the list', () => {
10         const initialState = undefined;
11         const collection = {
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 = collectionsReducer(initialState, actions.CREATE_COLLECTION(collection));
22         expect(state).toEqual([collection]);
23     });
24
25     it('should load collections', () => {
26         const initialState = undefined;
27         const collection = {
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 collections = [collection, collection];
38         const state = collectionsReducer(initialState, actions.COLLECTIONS_SUCCESS({ collections }));
39         expect(state).toEqual([collection, collection]);
40     });
41 });