Connect project dialog to the store
[arvados.git] / src / store / project / project-reducer.test.ts
index 65a856bddb8720109cf8d75f044d346c955c4de6..0862142d48b264e5bd84706d5e420dff06d07d9d 100644 (file)
@@ -21,7 +21,7 @@ describe('project-reducer', () => {
         };
 
         const state = projectsReducer(initialState, actions.CREATE_PROJECT(project));
-        expect(state).toEqual([project]);
+        expect(state.items[0].data).toEqual(project);
     });
 
     it('should load projects', () => {
@@ -38,22 +38,25 @@ describe('project-reducer', () => {
 
         const projects = [project, project];
         const state = projectsReducer(initialState, actions.PROJECTS_SUCCESS({ projects, parentItemId: undefined }));
-        expect(state).toEqual([{
-            active: false,
-            open: false,
-            id: "test123",
-            items: [],
-            data: project,
-            status: 0
-        }, {
-            active: false,
-            open: false,
-            id: "test123",
-            items: [],
-            data: project,
-            status: 0
-        }
-        ]);
+        expect(state).toEqual({
+            items: [{
+                active: false,
+                open: false,
+                id: "test123",
+                items: [],
+                data: project,
+                status: 0
+            }, {
+                active: false,
+                open: false,
+                id: "test123",
+                items: [],
+                data: project,
+                status: 0
+            }
+            ],
+            currentItemId: ""
+        });
     });
 
     it('should remove activity on projects list', () => {
@@ -73,7 +76,8 @@ describe('project-reducer', () => {
                 active: true,
                 status: 1
             }],
-            currentItemId: "1"
+            currentItemId: "1",
+            creator: { opened: false, pending: false, ownerUuid: "" },
         };
         const project = {
             items: [{
@@ -91,10 +95,10 @@ describe('project-reducer', () => {
                 active: false,
                 status: 1
             }],
-            currentItemId: "1"
+            currentItemId: ""
         };
 
-        const state = projectsReducer(initialState, actions.RESET_PROJECT_TREE_ACTIVITY(initialState[0].id));
+        const state = projectsReducer(initialState, actions.RESET_PROJECT_TREE_ACTIVITY(initialState.items[0].id));
         expect(state).toEqual(project);
     });
 
@@ -115,7 +119,8 @@ describe('project-reducer', () => {
                 active: false,
                 status: 1
             }],
-            currentItemId: "1"
+            currentItemId: "1",
+            creator: { opened: false, pending: false, ownerUuid: "" }
         };
         const project = {
             items: [{
@@ -126,17 +131,19 @@ describe('project-reducer', () => {
                     modifiedAt: '2018-01-01',
                     ownerUuid: 'owner-test123',
                     uuid: 'test123',
-                    kind: ResourceKind.PROJECT
+                    kind: ResourceKind.PROJECT,
                 },
                 id: "1",
                 open: true,
                 active: true,
-                status: 1
+                status: 1,
+                toggled: true
             }],
-            currentItemId: "1"
+            currentItemId: "1",
+            creator: { opened: false, pending: false, ownerUuid: "" },
         };
 
-        const state = projectsReducer(initialState, actions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(initialState[0].id));
+        const state = projectsReducer(initialState, actions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(initialState.items[0].id));
         expect(state).toEqual(project);
     });
 
@@ -159,7 +166,8 @@ describe('project-reducer', () => {
                 status: 1,
                 toggled: false,
             }],
-            currentItemId: "1"
+            currentItemId: "1",
+            creator: { opened: false, pending: false, ownerUuid: "" }
         };
         const project = {
             items: [{
@@ -178,10 +186,11 @@ describe('project-reducer', () => {
                 status: 1,
                 toggled: true
             }],
-            currentItemId: "1"
+            currentItemId: "1",
+            creator: { opened: false, pending: false, ownerUuid: "" },
         };
 
-        const state = projectsReducer(initialState, actions.TOGGLE_PROJECT_TREE_ITEM_OPEN(initialState[0].id));
+        const state = projectsReducer(initialState, actions.TOGGLE_PROJECT_TREE_ITEM_OPEN(initialState.items[0].id));
         expect(state).toEqual(project);
     });
 });