Added central action for navigation
[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 import { ResourceKind } from "../../models/resource";
8
9 describe('collection-reducer', () => {
10     it('should add new collection to the list', () => {
11         const initialState = undefined;
12         const collection = {
13             name: 'test',
14             href: 'href',
15             createdAt: '2018-01-01',
16             modifiedAt: '2018-01-01',
17             ownerUuid: 'owner-test123',
18             uuid: 'test123',
19             kind: ResourceKind.COLLECTION
20         };
21
22         const state = collectionsReducer(initialState, actions.CREATE_COLLECTION(collection));
23         expect(state).toEqual([collection]);
24     });
25
26     it('should load collections', () => {
27         const initialState = undefined;
28         const collection = {
29             name: 'test',
30             href: 'href',
31             createdAt: '2018-01-01',
32             modifiedAt: '2018-01-01',
33             ownerUuid: 'owner-test123',
34             uuid: 'test123',
35             kind: ResourceKind.COLLECTION
36         };
37
38         const collections = [collection, collection];
39         const state = collectionsReducer(initialState, actions.COLLECTIONS_SUCCESS({ collections }));
40         expect(state).toEqual([collection, collection]);
41     });
42 });