collection-creation-test
[arvados-workbench2.git] / src / store / collections / creator / collection-creator-reducer.test.ts
index df2c36280212b6730235d068134bda236e2eca41..0da18c81ef319b28b81674b68fb7feff423f5d43 100644 (file)
@@ -1,3 +1,45 @@
 // Copyright (C) The Arvados Authors. All rights reserved.
 //
-// SPDX-License-Identifier: AGPL-3.0
\ No newline at end of file
+// SPDX-License-Identifier: AGPL-3.0
+
+import { collectionCreationReducer } from "./collection-creator-reducer";
+import { collectionCreateActions } from "./collection-creator-action";
+
+describe('collection-reducer', () => {
+
+    it('should open collection creator dialog', () => {
+        const initialState = {
+            creator: { opened: false, ownerUuid: "" }
+        };
+        const collection = {
+            creator: { opened: true, ownerUuid: "" },
+        };
+
+        const state = collectionCreationReducer(initialState, collectionCreateActions.OPEN_COLLECTION_CREATOR(initialState.creator));
+        expect(state).toEqual(collection);
+    });
+
+    it('should close collection creator dialog', () => {
+        const initialState = {
+            creator: { opened: true, ownerUuid: "" }
+        };
+        const collection = {
+            creator: { opened: false, ownerUuid: "" },
+        };
+
+        const state = collectionCreationReducer(initialState, collectionCreateActions.CLOSE_COLLECTION_CREATOR());
+        expect(state).toEqual(collection);
+    });
+
+    it('should reset collection creator dialog props', () => {
+        const initialState = {
+            creator: { opened: true, ownerUuid: "test" }
+        };
+        const collection = {
+            creator: { opened: false, ownerUuid: "" },
+        };
+
+        const state = collectionCreationReducer(initialState, collectionCreateActions.CREATE_COLLECTION_SUCCESS());
+        expect(state).toEqual(collection);
+    });
+});
\ No newline at end of file