2017-08-04 18:02:44 -06:00
|
|
|
import * as React from "react";
|
|
|
|
import { mount } from "enzyme";
|
|
|
|
import { AxisInputBoxGroup } from "../axis_input_box_group";
|
|
|
|
|
|
|
|
describe("<AxisInputBoxGroup />", () => {
|
2017-08-10 18:59:01 -06:00
|
|
|
beforeEach(function () {
|
|
|
|
jest.clearAllMocks();
|
|
|
|
});
|
|
|
|
|
2017-08-28 05:49:13 -06:00
|
|
|
const props = {
|
2017-08-10 18:59:01 -06:00
|
|
|
position: { x: undefined, y: undefined, z: undefined },
|
|
|
|
onCommit: jest.fn(),
|
|
|
|
disabled: false
|
|
|
|
};
|
2017-08-04 18:02:44 -06:00
|
|
|
|
|
|
|
it("has 3 inputs and a button", () => {
|
2017-08-28 05:49:13 -06:00
|
|
|
const wrapper = mount(<AxisInputBoxGroup {...props} />);
|
2017-08-04 18:02:44 -06:00
|
|
|
expect(wrapper.find("input").length).toEqual(3);
|
2017-08-28 05:49:13 -06:00
|
|
|
const buttons = wrapper.find("button");
|
2017-08-04 18:02:44 -06:00
|
|
|
expect(buttons.length).toEqual(1);
|
|
|
|
expect(buttons.text().toLowerCase()).toEqual("go");
|
|
|
|
buttons.simulate("click");
|
2017-08-10 18:59:01 -06:00
|
|
|
expect(props.onCommit).toHaveBeenCalledWith({ "x": 0, "y": 0, "z": 0 });
|
|
|
|
|
2017-08-04 18:02:44 -06:00
|
|
|
});
|
2017-08-10 18:59:01 -06:00
|
|
|
|
|
|
|
it("button is disabled", () => {
|
|
|
|
props.disabled = true;
|
2017-08-28 05:49:13 -06:00
|
|
|
const wrapper = mount(<AxisInputBoxGroup {...props} />);
|
2017-08-10 18:59:01 -06:00
|
|
|
wrapper.find("button").simulate("click");
|
|
|
|
expect(props.onCommit).not.toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
2017-08-04 18:02:44 -06:00
|
|
|
});
|