From afa829ac853b470517757951c51c6a8b1316f0f1 Mon Sep 17 00:00:00 2001 From: Daniel Kos Date: Tue, 26 Jun 2018 13:27:47 +0200 Subject: [PATCH] Fixed test passing No issue # Arvados-DCO-1.1-Signed-off-by: Daniel Kos --- src/store/project/project-reducer.test.ts | 45 ++++++++++--------- .../project-tree/project-tree.test.tsx | 16 ++++--- src/views/workbench/workbench.test.tsx | 11 ++++- 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/store/project/project-reducer.test.ts b/src/store/project/project-reducer.test.ts index 65a856bd..f4301040 100644 --- a/src/store/project/project-reducer.test.ts +++ b/src/store/project/project-reducer.test.ts @@ -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); }); }); diff --git a/src/views-components/project-tree/project-tree.test.tsx b/src/views-components/project-tree/project-tree.test.tsx index 1ba3abb8..7725da54 100644 --- a/src/views-components/project-tree/project-tree.test.tsx +++ b/src/views-components/project-tree/project-tree.test.tsx @@ -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, diff --git a/src/views/workbench/workbench.test.tsx b/src/views/workbench/workbench.test.tsx index 69257922..6edebaf0 100644 --- a/src/views/workbench/workbench.test.tsx +++ b/src/views/workbench/workbench.test.tsx @@ -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( -- 2.30.2