Merge branch '13893-collection-creation'
[arvados-workbench2.git] / src / store / collections / creator / collection-creator-reducer.test.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { collectionCreationReducer } from "./collection-creator-reducer";
6 import { collectionCreateActions } from "./collection-creator-action";
7
8 describe('collection-reducer', () => {
9
10     it('should open collection creator dialog', () => {
11         const initialState = {
12             creator: { opened: false, ownerUuid: "" }
13         };
14         const collection = {
15             creator: { opened: true, ownerUuid: "" },
16         };
17
18         const state = collectionCreationReducer(initialState, collectionCreateActions.OPEN_COLLECTION_CREATOR(initialState.creator));
19         expect(state).toEqual(collection);
20     });
21
22     it('should close collection creator dialog', () => {
23         const initialState = {
24             creator: { opened: true, ownerUuid: "" }
25         };
26         const collection = {
27             creator: { opened: false, ownerUuid: "" },
28         };
29
30         const state = collectionCreationReducer(initialState, collectionCreateActions.CLOSE_COLLECTION_CREATOR());
31         expect(state).toEqual(collection);
32     });
33
34     it('should reset collection creator dialog props', () => {
35         const initialState = {
36             creator: { opened: true, ownerUuid: "test" }
37         };
38         const collection = {
39             creator: { opened: false, ownerUuid: "" },
40         };
41
42         const state = collectionCreationReducer(initialState, collectionCreateActions.CREATE_COLLECTION_SUCCESS());
43         expect(state).toEqual(collection);
44     });
45 });