2017-07-30 16:19:45 -06:00
|
|
|
import * as React from "react";
|
|
|
|
import { TileIf } from "../tile_if";
|
|
|
|
import { mount } from "enzyme";
|
|
|
|
import { fakeSequence } from "../../../__test_support__/fake_state/resources";
|
|
|
|
import { If } from "farmbot/dist";
|
2018-10-29 18:13:41 -06:00
|
|
|
import { emptyState } from "../../../resources/reducer";
|
2017-07-30 16:19:45 -06:00
|
|
|
|
|
|
|
describe("<TileIf/>", () => {
|
|
|
|
function bootstrapTest() {
|
|
|
|
const currentStep: If = {
|
|
|
|
kind: "_if",
|
|
|
|
args: {
|
|
|
|
lhs: "pin0",
|
|
|
|
op: "is",
|
|
|
|
rhs: 0,
|
|
|
|
_then: { kind: "nothing", args: {} },
|
|
|
|
_else: { kind: "nothing", args: {} }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return {
|
|
|
|
component: mount(<TileIf
|
|
|
|
currentSequence={fakeSequence()}
|
|
|
|
currentStep={currentStep}
|
|
|
|
dispatch={jest.fn()}
|
|
|
|
index={0}
|
2018-08-30 19:25:58 -06:00
|
|
|
resources={emptyState().index}
|
2019-04-18 16:58:29 -06:00
|
|
|
confirmStepDeletion={false}
|
|
|
|
showPins={true} />)
|
2017-07-30 16:19:45 -06:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
it("renders inputs", () => {
|
2017-08-28 05:49:13 -06:00
|
|
|
const block = bootstrapTest().component;
|
|
|
|
const inputs = block.find("input");
|
|
|
|
const labels = block.find("label");
|
|
|
|
const buttons = block.find("button");
|
2017-07-30 16:19:45 -06:00
|
|
|
expect(inputs.length).toEqual(2);
|
|
|
|
expect(labels.length).toEqual(5);
|
|
|
|
expect(buttons.length).toEqual(4);
|
2019-09-01 09:04:32 -06:00
|
|
|
expect(inputs.first().props().placeholder).toEqual("If ...");
|
2017-07-30 16:19:45 -06:00
|
|
|
expect(labels.at(0).text()).toEqual("Variable");
|
|
|
|
expect(buttons.at(0).text()).toEqual("Pin 0");
|
|
|
|
expect(labels.at(1).text()).toEqual("Operator");
|
|
|
|
expect(buttons.at(1).text()).toEqual("is");
|
|
|
|
expect(labels.at(2).text()).toEqual("Value");
|
|
|
|
expect(inputs.at(1).props().value).toEqual(0);
|
2019-09-01 09:04:32 -06:00
|
|
|
expect(labels.at(3).text()).toEqual("Then Execute");
|
2017-07-30 16:19:45 -06:00
|
|
|
expect(buttons.at(2).text()).toEqual("None");
|
2019-09-01 09:04:32 -06:00
|
|
|
expect(labels.at(4).text()).toEqual("Else Execute");
|
2017-07-30 16:19:45 -06:00
|
|
|
expect(buttons.at(3).text()).toEqual("None");
|
|
|
|
});
|
|
|
|
});
|