Fixed test passing
authorDaniel Kos <daniel.kos@contractors.roche.com>
Tue, 26 Jun 2018 11:27:47 +0000 (13:27 +0200)
committerDaniel Kos <daniel.kos@contractors.roche.com>
Tue, 26 Jun 2018 11:28:13 +0000 (13:28 +0200)
No issue #

Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos@contractors.roche.com>

src/store/project/project-reducer.test.ts
src/views-components/project-tree/project-tree.test.tsx
src/views/workbench/workbench.test.tsx

index 65a856bddb8720109cf8d75f044d346c955c4de6..f4301040d5b165b709092892873245e9c6c3ca1c 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', () => {
@@ -91,10 +94,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);
     });
 
@@ -136,7 +139,7 @@ describe('project-reducer', () => {
             currentItemId: "1"
         };
 
-        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);
     });
 
@@ -181,7 +184,7 @@ describe('project-reducer', () => {
             currentItemId: "1"
         };
 
-        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);
     });
 });
index 1ba3abb8bb39ddb2c40de1098b769b35bd7ad105..7725da5403810df2fb123cf96b7d563b3b2355fd 100644 (file)
@@ -3,8 +3,8 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { mount } from 'enzyme';
 import * as Enzyme from 'enzyme';
+import { mount } from 'enzyme';
 import * as Adapter from 'enzyme-adapter-react-16';
 import ListItemIcon from '@material-ui/core/ListItemIcon';
 import { Collapse } from '@material-ui/core';
@@ -13,6 +13,8 @@ import CircularProgress from '@material-ui/core/CircularProgress';
 import ProjectTree from './project-tree';
 import { TreeItem } from '../../components/tree/tree';
 import { Project } from '../../models/project';
+import { ResourceKind } from "../../models/resource";
+
 Enzyme.configure({ adapter: new Adapter() });
 
 describe("ProjectTree component", () => {
@@ -26,7 +28,7 @@ describe("ProjectTree component", () => {
                 uuid: "uuid",
                 ownerUuid: "ownerUuid",
                 href: "href",
-                kind: 'example'
+                kind: ResourceKind.PROJECT
             },
             id: "3",
             open: true,
@@ -48,7 +50,7 @@ describe("ProjectTree component", () => {
                     uuid: "uuid",
                     ownerUuid: "ownerUuid",
                     href: "href",
-                    kind: 'example'
+                    kind: ResourceKind.PROJECT
                 },
                 id: "3",
                 open: false,
@@ -63,7 +65,7 @@ describe("ProjectTree component", () => {
                     uuid: "uuid",
                     ownerUuid: "ownerUuid",
                     href: "href",
-                    kind: 'example'
+                    kind: ResourceKind.PROJECT
                 },
                 id: "3",
                 open: false,
@@ -86,7 +88,7 @@ describe("ProjectTree component", () => {
                     uuid: "uuid",
                     ownerUuid: "ownerUuid",
                     href: "href",
-                    kind: 'example'
+                    kind: ResourceKind.PROJECT
                 },
                 id: "3",
                 open: true,
@@ -101,7 +103,7 @@ describe("ProjectTree component", () => {
                             uuid: "uuid",
                             ownerUuid: "ownerUuid",
                             href: "href",
-                            kind: 'example'
+                            kind: ResourceKind.PROJECT
                         },
                         id: "3",
                         open: true,
@@ -125,7 +127,7 @@ describe("ProjectTree component", () => {
                 uuid: "uuid",
                 ownerUuid: "ownerUuid",
                 href: "href",
-                kind: 'example'
+                kind: ResourceKind.PROJECT
             },
             id: "3",
             open: false,
index 6925792293b65c475539ddd9e0a9bf279cb02f9e..6edebaf0887bc5598391256ee813ed6949d2ec94 100644 (file)
@@ -14,7 +14,16 @@ const history = createBrowserHistory();
 
 it('renders without crashing', () => {
     const div = document.createElement('div');
-    const store = configureStore({ projects: [], router: { location: null }, auth: {}, sidePanel: [] }, createBrowserHistory());
+    const store = configureStore({
+        projects: {
+            items: [],
+            currentItemId: ""
+        },
+        collections: [],
+        router: { location: null },
+        auth: {},
+        sidePanel: []
+    }, createBrowserHistory());
     ReactDOM.render(
         <Provider store={store}>
             <ConnectedRouter history={history}>