};
const state = projectsReducer(initialState, actions.CREATE_PROJECT(project));
- expect(state).toEqual([project]);
+ expect(state.items[0].data).toEqual(project);
});
it('should load projects', () => {
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', () => {
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);
});
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);
});
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);
});
});
// 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';
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", () => {
uuid: "uuid",
ownerUuid: "ownerUuid",
href: "href",
- kind: 'example'
+ kind: ResourceKind.PROJECT
},
id: "3",
open: true,
uuid: "uuid",
ownerUuid: "ownerUuid",
href: "href",
- kind: 'example'
+ kind: ResourceKind.PROJECT
},
id: "3",
open: false,
uuid: "uuid",
ownerUuid: "ownerUuid",
href: "href",
- kind: 'example'
+ kind: ResourceKind.PROJECT
},
id: "3",
open: false,
uuid: "uuid",
ownerUuid: "ownerUuid",
href: "href",
- kind: 'example'
+ kind: ResourceKind.PROJECT
},
id: "3",
open: true,
uuid: "uuid",
ownerUuid: "ownerUuid",
href: "href",
- kind: 'example'
+ kind: ResourceKind.PROJECT
},
id: "3",
open: true,
uuid: "uuid",
ownerUuid: "ownerUuid",
href: "href",
- kind: 'example'
+ kind: ResourceKind.PROJECT
},
id: "3",
open: false,
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}>