add tools tests
parent
f39f4ecf77
commit
7bb161b96c
|
@ -260,6 +260,15 @@ export let FAKE_RESOURCES: TaggedResource[] = [
|
|||
"status": "active"
|
||||
},
|
||||
"uuid": "tools.14.49"
|
||||
},
|
||||
{
|
||||
"kind": "tools",
|
||||
"body": {
|
||||
"id": 15,
|
||||
"name": "Berry Picking Tool",
|
||||
"status": "inactive"
|
||||
},
|
||||
"uuid": "tools.15.50"
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
import * as React from "react";
|
||||
import { ToolList } from "../tool_list";
|
||||
import { mount } from "enzyme";
|
||||
import { mapStateToProps } from "../../state_to_props";
|
||||
import { fakeState } from "../../../__test_support__/fake_state";
|
||||
|
||||
describe("<ToolList />", () => {
|
||||
function bootstrapTest() {
|
||||
let state = fakeState();
|
||||
let toggle = jest.fn();
|
||||
let props = mapStateToProps(state);
|
||||
return {
|
||||
state,
|
||||
toggle,
|
||||
props,
|
||||
component: mount(<ToolList dispatch={state.dispatch}
|
||||
tools={props.tools}
|
||||
toggle={toggle}
|
||||
isActive={props.isActive} />)
|
||||
};
|
||||
}
|
||||
it("renders tool names and statuses", () => {
|
||||
let test = bootstrapTest();
|
||||
expect(test.component.text()).toContain("Trench Digging Toolactive");
|
||||
expect(test.component.text()).toContain("Berry Picking Toolinactive");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,33 @@
|
|||
import * as React from "react";
|
||||
import { ToolBayForm } from "../toolbay_form";
|
||||
import { mount } from "enzyme";
|
||||
import { mapStateToProps } from "../../state_to_props";
|
||||
import { fakeState } from "../../../__test_support__/fake_state";
|
||||
|
||||
describe("<ToolBayForm/>", () => {
|
||||
function bootstrapTest() {
|
||||
let state = fakeState();
|
||||
let toggle = jest.fn();
|
||||
let props = mapStateToProps(state);
|
||||
return {
|
||||
state,
|
||||
toggle,
|
||||
props,
|
||||
component: mount(<ToolBayForm
|
||||
toggle={toggle}
|
||||
dispatch={state.dispatch}
|
||||
toolSlots={props.toolSlots}
|
||||
getToolSlots={props.getToolSlots}
|
||||
getChosenToolOption={props.getChosenToolOption}
|
||||
getToolOptions={props.getToolOptions}
|
||||
changeToolSlot={props.changeToolSlot} />)
|
||||
};
|
||||
}
|
||||
it("renders", () => {
|
||||
let test = bootstrapTest();
|
||||
|
||||
expect(test.component.find("input").length).toEqual(3);
|
||||
expect(test.component.text()).toContain("Trench Digging Tool");
|
||||
});
|
||||
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
import * as React from "react";
|
||||
import { ToolBayHeader } from "../toolbay_header";
|
||||
import { mount } from "enzyme";
|
||||
|
||||
describe("<ToolBayHeader />", () => {
|
||||
it("renders", () => {
|
||||
let header = mount(<ToolBayHeader />);
|
||||
expect(header.text()).toEqual("SlotXYZTool");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,26 @@
|
|||
import * as React from "react";
|
||||
import { ToolBayList } from "../toolbay_list";
|
||||
import { mount } from "enzyme";
|
||||
import { mapStateToProps } from "../../state_to_props";
|
||||
import { fakeState } from "../../../__test_support__/fake_state";
|
||||
|
||||
describe("<ToolBayList />", () => {
|
||||
function bootstrapTest() {
|
||||
let state = fakeState();
|
||||
let toggle = jest.fn();
|
||||
let props = mapStateToProps(state);
|
||||
return {
|
||||
state,
|
||||
toggle,
|
||||
props,
|
||||
component: mount(<ToolBayList dispatch={state.dispatch}
|
||||
getToolByToolSlotUUID={props.getToolByToolSlotUUID}
|
||||
getToolSlots={props.getToolSlots}
|
||||
toggle={toggle} />)
|
||||
};
|
||||
}
|
||||
it("renders", () => {
|
||||
let test = bootstrapTest();
|
||||
expect(test.component.text()).toContain("1101010Trench Digging Tool");
|
||||
});
|
||||
});
|
|
@ -20,7 +20,7 @@ export class ToolForm extends React.Component<ToolFormProps, {}> {
|
|||
uuid: "ERROR: GENERATED BY REDUCER - UUID SHOULD BE UNSEEN",
|
||||
kind: "tools",
|
||||
body: { name: "Tool " + (this.props.tools.length + 1) }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -80,4 +80,4 @@ export class ToolForm extends React.Component<ToolFormProps, {}> {
|
|||
</WidgetBody>
|
||||
</Widget>;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -37,4 +37,4 @@ export class ToolList extends React.Component<ToolListProps, {}> {
|
|||
</WidgetBody>
|
||||
</Widget>;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ export class ToolBayForm extends React.Component<ToolBayFormProps, {}> {
|
|||
tool_id: undefined,
|
||||
name: "Tool Slot"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -119,10 +119,10 @@ export class ToolBayForm extends React.Component<ToolBayFormProps, {}> {
|
|||
<i className="fa fa-times" />
|
||||
</button>
|
||||
</Col>
|
||||
</Row>
|
||||
</Row>;
|
||||
})}
|
||||
</WidgetBody>
|
||||
</Widget>
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,6 @@ export class ToolBayList extends React.Component<ToolBayListProps, {}> {
|
|||
</Row>;
|
||||
})}
|
||||
</WidgetBody>
|
||||
</Widget>
|
||||
</Widget>;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue