[UNSTABLE] Many type errors after upgrade
parent
3afcb3972a
commit
fdc504b4b9
16
package.json
16
package.json
|
@ -30,15 +30,15 @@
|
|||
"@blueprintjs/core": "2.3.1",
|
||||
"@blueprintjs/datetime": "2.0.3",
|
||||
"@blueprintjs/select": "^2.0.1",
|
||||
"@types/enzyme": "3.1.10",
|
||||
"@types/enzyme": "3.1.11",
|
||||
"@types/fastclick": "^1.0.28",
|
||||
"@types/history": "^4.6.1",
|
||||
"@types/i18next": "^8.4.2",
|
||||
"@types/jest": "23.1.1",
|
||||
"@types/jest": "23.1.4",
|
||||
"@types/lodash": "4.14.110",
|
||||
"@types/markdown-it": "^0.0.4",
|
||||
"@types/moxios": "^0.4.5",
|
||||
"@types/node": "10.3.5",
|
||||
"@types/node": "10.5.1",
|
||||
"@types/react": "16.3.14",
|
||||
"@types/react-color": "2.13.5",
|
||||
"@types/react-dom": "16.0.5",
|
||||
|
@ -47,7 +47,7 @@
|
|||
"axios": "^0.18.0",
|
||||
"boxed_value": "^1.0.0",
|
||||
"browser-speech": "1.1.1",
|
||||
"coveralls": "3.0.1",
|
||||
"coveralls": "3.0.2",
|
||||
"css-loader": "0.28.11",
|
||||
"enzyme": "^3.1.0",
|
||||
"enzyme-adapter-react-16": "^1.1.0",
|
||||
|
@ -65,7 +65,7 @@
|
|||
"moment": "2.22.2",
|
||||
"moxios": "^0.4.0",
|
||||
"node-sass": "4.9.0",
|
||||
"optimize-css-assets-webpack-plugin": "4.0.2",
|
||||
"optimize-css-assets-webpack-plugin": "4.0.3",
|
||||
"raf": "^3.4.0",
|
||||
"react": "16.4.1",
|
||||
"react-addons-css-transition-group": "^15.6.2",
|
||||
|
@ -83,13 +83,13 @@
|
|||
"sass-loader": "7.0.3",
|
||||
"stats-webpack-plugin": "0.6.2",
|
||||
"style-loader": "0.21.0",
|
||||
"ts-jest": "22.4.6",
|
||||
"ts-jest": "23.0.0",
|
||||
"ts-lint": "^4.5.1",
|
||||
"ts-loader": "^4.4.1",
|
||||
"ts-loader": "4.4.2",
|
||||
"tslint": "5.10.0",
|
||||
"typescript": "2.9.2",
|
||||
"url-loader": "1.0.1",
|
||||
"webpack": "4.12.1",
|
||||
"webpack": "4.14.0",
|
||||
"webpack-uglify-js-plugin": "1.1.9",
|
||||
"weinre": "^2.0.0-pre-I0Z7U9OV",
|
||||
"which": "1.3.1",
|
||||
|
|
|
@ -36,7 +36,7 @@ describe("<App />: Controls Pop-Up", () => {
|
|||
function controlsPopUp(page: string, exists: boolean) {
|
||||
it(`doesn't render controls pop-up on ${page} page`, () => {
|
||||
mockPath = "/app/" + page;
|
||||
const wrapper = mount(<App {...fakeProps()} />);
|
||||
const wrapper = mount<App>(<App {...fakeProps()} />);
|
||||
if (exists) {
|
||||
expect(wrapper.html()).toContain("controls-popup");
|
||||
} else {
|
||||
|
@ -60,34 +60,34 @@ describe("<App />: Controls Pop-Up", () => {
|
|||
|
||||
describe("<App />: Loading", () => {
|
||||
it("MUST_LOADs not loaded", () => {
|
||||
const wrapper = mount(<App {...fakeProps()} />);
|
||||
const wrapper = mount<App>(<App {...fakeProps()} />);
|
||||
expect(wrapper.text()).toContain("Loading...");
|
||||
});
|
||||
|
||||
it("MUST_LOADs partially loaded", () => {
|
||||
const p = fakeProps();
|
||||
p.loaded = ["Sequence"];
|
||||
const wrapper = mount(<App {...p} />);
|
||||
const wrapper = mount<App>(<App {...p} />);
|
||||
expect(wrapper.text()).toContain("Loading...");
|
||||
});
|
||||
|
||||
it("MUST_LOADs loaded", () => {
|
||||
const p = fakeProps();
|
||||
p.loaded = ["Sequence", "Regimen", "FarmEvent", "Point"];
|
||||
const wrapper = mount(<App {...p} />);
|
||||
const wrapper = mount<App>(<App {...p} />);
|
||||
expect(wrapper.text()).not.toContain("Loading...");
|
||||
});
|
||||
});
|
||||
|
||||
describe("<App />: NavBar", () => {
|
||||
it("displays links", () => {
|
||||
const wrapper = mount(<App {...fakeProps()} />);
|
||||
const wrapper = mount<App>(<App {...fakeProps()} />);
|
||||
expect(wrapper.text())
|
||||
.toContain("Farm DesignerControlsDeviceSequencesRegimensToolsFarmware");
|
||||
});
|
||||
|
||||
it("displays ticker", () => {
|
||||
const wrapper = mount(<App {...fakeProps()} />);
|
||||
const wrapper = mount<App>(<App {...fakeProps()} />);
|
||||
expect(wrapper.text()).toContain("No logs yet.");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,7 +31,7 @@ describe("<ControlsPopup />", () => {
|
|||
|
||||
const p = fakeProps();
|
||||
p.axisInversion.x = true;
|
||||
const wrapper = mount(<ControlsPopup {...p} />);
|
||||
const wrapper =mount<>(<ControlsPopup {...p} />);
|
||||
|
||||
it("Has a false initial state", () => {
|
||||
expect(wrapper.state("isOpen")).toBeFalsy();
|
||||
|
@ -68,7 +68,7 @@ describe("<ControlsPopup />", () => {
|
|||
it("swaps axes", () => {
|
||||
const swappedProps = fakeProps();
|
||||
swappedProps.xySwap = true;
|
||||
const swapped = mount(<ControlsPopup {...swappedProps} />);
|
||||
const swapped =mount<>(<ControlsPopup {...swappedProps} />);
|
||||
swapped.setState({ isOpen: true });
|
||||
expect(swapped.state("isOpen")).toBeTruthy();
|
||||
const button = swapped.find("button").at(1);
|
||||
|
|
|
@ -22,7 +22,7 @@ describe("<CrashPage/>", () => {
|
|||
message: "@@@ERROR@@@"
|
||||
};
|
||||
const CrashPage = crashPage(fakeError);
|
||||
const el = mount(<CrashPage />);
|
||||
const el =mount<>(<CrashPage />);
|
||||
const html = el.html();
|
||||
expect(html).toContain(fakeError.message);
|
||||
expect(html).toContain(fakeError.stack[0]);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
jest.mock("../util/errors.ts", () => ({ catchErrors: jest.fn() }));
|
||||
|
||||
import * as React from "react";
|
||||
import { mount, ReactWrapper } from "enzyme";
|
||||
import { mount } from "enzyme";
|
||||
import { ErrorBoundary } from "../error_boundary";
|
||||
import { catchErrors } from "../util";
|
||||
|
||||
|
@ -20,8 +20,7 @@ class Kaboom extends React.Component<{}, {}> {
|
|||
describe("<ErrorBoundary/>", () => {
|
||||
it("handles exceptions", () => {
|
||||
const nodes = <ErrorBoundary><Kaboom /></ErrorBoundary>;
|
||||
type X = ReactWrapper<{}, ErrorBoundary["state"]>;
|
||||
const el: X = mount(nodes);
|
||||
const el = mount<ErrorBoundary>(nodes);
|
||||
expect(el.text()).toContain("can't render this part of the page");
|
||||
const i = el.instance();
|
||||
expect(i.state.hasError).toBe(true);
|
||||
|
|
|
@ -4,7 +4,7 @@ import { FourOhFour } from "../404";
|
|||
|
||||
describe("<FourOhFour/>", function () {
|
||||
it("renders helpful text", function () {
|
||||
const dom = mount(<FourOhFour />);
|
||||
const dom =mount<>(<FourOhFour />);
|
||||
expect(dom.html()).toContain("Page Not Found");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ import { mount } from "enzyme";
|
|||
describe("<DeleteAccount/>", () => {
|
||||
it("executes account deletion", () => {
|
||||
const fn = jest.fn();
|
||||
const el = mount(<DeleteAccount onClick={fn} />);
|
||||
const el =mount<>(<DeleteAccount onClick={fn} />);
|
||||
el.setState({ password: "123" });
|
||||
el.find("button.red").last().simulate("click");
|
||||
expect(fn).toHaveBeenCalledTimes(1);
|
||||
|
|
|
@ -16,7 +16,7 @@ describe("<Account />", () => {
|
|||
const props = mapStateToProps(fakeState());
|
||||
props.dispatch = jest.fn();
|
||||
|
||||
const el = mount(<Account {...props} />);
|
||||
const el =mount<>(<Account {...props} />);
|
||||
expect(() => {
|
||||
(el.instance() as Account).onChange({
|
||||
currentTarget: {
|
||||
|
@ -39,7 +39,7 @@ describe("<Account />", () => {
|
|||
it("triggers the onSave() event", () => {
|
||||
const props = mapStateToProps(fakeState());
|
||||
props.dispatch = jest.fn(() => Promise.resolve({}));
|
||||
const el = mount(<Account {...props} />);
|
||||
const el =mount<>(<Account {...props} />);
|
||||
|
||||
(el.instance() as Account).onSave();
|
||||
expect(props.dispatch).toHaveBeenCalledTimes(1);
|
||||
|
|
|
@ -11,7 +11,7 @@ describe("<Settings/>", function () {
|
|||
onChange: jest.fn(),
|
||||
onSave: jest.fn()
|
||||
};
|
||||
const dom = mount(<Settings {...props} />);
|
||||
const dom =mount<>(<Settings {...props} />);
|
||||
expect(props.onSave).not.toHaveBeenCalled();
|
||||
dom.find("button").simulate("click");
|
||||
expect(props.onSave).toHaveBeenCalled();
|
||||
|
|
|
@ -21,7 +21,7 @@ import { LabsFeatures } from "../labs_features";
|
|||
|
||||
describe("<LabsFeatures/>", () => {
|
||||
it("triggers the correct callback on click", () => {
|
||||
const el = mount(<LabsFeatures />);
|
||||
const el =mount<>(<LabsFeatures />);
|
||||
expect(mocks.fetchLabFeatures.mock.calls.length).toBeGreaterThan(0);
|
||||
el.find("button").simulate("click");
|
||||
expect(mockFeatures[0].callback).toHaveBeenCalled();
|
||||
|
|
|
@ -17,7 +17,7 @@ describe("<AxisInputBoxGroup />", () => {
|
|||
};
|
||||
|
||||
it("has 3 inputs and a button", () => {
|
||||
const wrapper = mount(<AxisInputBoxGroup {...props} />);
|
||||
const wrapper =mount<>(<AxisInputBoxGroup {...props} />);
|
||||
expect(wrapper.find("input").length).toEqual(3);
|
||||
expect(wrapper.find("button").length).toEqual(1);
|
||||
|
||||
|
@ -25,13 +25,13 @@ describe("<AxisInputBoxGroup />", () => {
|
|||
|
||||
it("button is disabled", () => {
|
||||
props.disabled = true;
|
||||
const wrapper = mount(<AxisInputBoxGroup {...props} />);
|
||||
const wrapper =mount<>(<AxisInputBoxGroup {...props} />);
|
||||
wrapper.find("button").simulate("click");
|
||||
expect(props.onCommit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("changes", () => {
|
||||
const wrapper = mount(<AxisInputBoxGroup {...props} />);
|
||||
const wrapper =mount<>(<AxisInputBoxGroup {...props} />);
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = wrapper.instance() as any;
|
||||
instance.change("x", 10);
|
||||
|
@ -44,7 +44,7 @@ describe("<AxisInputBoxGroup />", () => {
|
|||
it(`Go: ${testCase}`, () => {
|
||||
props.disabled = false;
|
||||
props.position = coordinates.position;
|
||||
const wrapper = mount(<AxisInputBoxGroup {...props} />);
|
||||
const wrapper =mount<>(<AxisInputBoxGroup {...props} />);
|
||||
wrapper.setState(coordinates.inputs);
|
||||
clickButton(wrapper, 0, "go");
|
||||
expect(props.onCommit).toHaveBeenCalledWith(coordinates.expected);
|
||||
|
|
|
@ -7,7 +7,7 @@ describe("<AxisInputBox/>", () => {
|
|||
function inputBoxWithValue(value: number | undefined) {
|
||||
const axis: Xyz = "x";
|
||||
const props = { axis, value, onChange: jest.fn() };
|
||||
return mount(<AxisInputBox {...props } />);
|
||||
returnmount<>(<AxisInputBox {...props } />);
|
||||
}
|
||||
|
||||
it("renders 0 if 0", () => {
|
||||
|
|
|
@ -32,7 +32,7 @@ describe("<Controls />", () => {
|
|||
|
||||
it("shows webcam widget", () => {
|
||||
mockConfig.hide_webcam_widget = false;
|
||||
const wrapper = mount(<Controls {...fakeProps()} />);
|
||||
const wrapper =mount<>(<Controls {...fakeProps()} />);
|
||||
const txt = wrapper.text().toLowerCase();
|
||||
["webcam", "move", "peripherals", "sensors"]
|
||||
.map(string => expect(txt).toContain(string));
|
||||
|
@ -40,7 +40,7 @@ describe("<Controls />", () => {
|
|||
|
||||
it("hides webcam widget", () => {
|
||||
mockConfig.hide_webcam_widget = true;
|
||||
const wrapper = mount(<Controls {...fakeProps()} />);
|
||||
const wrapper =mount<>(<Controls {...fakeProps()} />);
|
||||
const txt = wrapper.text().toLowerCase();
|
||||
["move", "peripherals", "sensors"]
|
||||
.map(string => expect(txt).toContain(string));
|
||||
|
@ -50,7 +50,7 @@ describe("<Controls />", () => {
|
|||
it("doesn't show sensors", () => {
|
||||
const p = fakeProps();
|
||||
p.shouldDisplay = () => false;
|
||||
const wrapper = mount(<Controls {...p} />);
|
||||
const wrapper =mount<>(<Controls {...p} />);
|
||||
const txt = wrapper.text().toLowerCase();
|
||||
expect(txt).not.toContain("sensors");
|
||||
});
|
||||
|
|
|
@ -39,20 +39,20 @@ describe("<DirectionButton/>", function () {
|
|||
});
|
||||
|
||||
it("calls move command", () => {
|
||||
const btn = mount(<DirectionButton {...buttonProps} />);
|
||||
const btn =mount<>(<DirectionButton {...buttonProps} />);
|
||||
btn.simulate("click");
|
||||
expect(mockDevice.moveRelative).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("is disabled", () => {
|
||||
buttonProps.disabled = true;
|
||||
const btn = mount(<DirectionButton {...buttonProps} />);
|
||||
const btn =mount<>(<DirectionButton {...buttonProps} />);
|
||||
btn.simulate("click");
|
||||
expect(mockDevice.moveRelative).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("call has correct args", () => {
|
||||
const btn = mount(<DirectionButton {...buttonProps} />);
|
||||
const btn =mount<>(<DirectionButton {...buttonProps} />);
|
||||
btn.simulate("click");
|
||||
expect(mockDevice.moveRelative)
|
||||
.toHaveBeenCalledWith({ speed: 100, x: 0, y: 1000, z: 0 });
|
||||
|
|
|
@ -35,7 +35,7 @@ describe("<JogButtons/>", function () {
|
|||
};
|
||||
|
||||
it("calls home command", () => {
|
||||
const jogButtons = mount(<JogButtons {...jogButtonProps()} />);
|
||||
const jogButtons =mount<>(<JogButtons {...jogButtonProps()} />);
|
||||
jogButtons.find("button").at(3).simulate("click");
|
||||
expect(mockDevice.home).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
@ -43,7 +43,7 @@ describe("<JogButtons/>", function () {
|
|||
it("calls find home command", () => {
|
||||
const p = jogButtonProps();
|
||||
p.doFindHome = true;
|
||||
const jogButtons = mount(<JogButtons {...p} />);
|
||||
const jogButtons =mount<>(<JogButtons {...p} />);
|
||||
jogButtons.find("button").at(3).simulate("click");
|
||||
expect(mockDevice.findHome).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
@ -51,26 +51,26 @@ describe("<JogButtons/>", function () {
|
|||
it("is disabled", () => {
|
||||
const p = jogButtonProps();
|
||||
p.arduinoBusy = true;
|
||||
const jogButtons = mount(<JogButtons {...p} />);
|
||||
const jogButtons =mount<>(<JogButtons {...p} />);
|
||||
jogButtons.find("button").at(3).simulate("click");
|
||||
expect(mockDevice.home).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("call has correct args", () => {
|
||||
const jogButtons = mount(<JogButtons {...jogButtonProps()} />);
|
||||
const jogButtons =mount<>(<JogButtons {...jogButtonProps()} />);
|
||||
jogButtons.find("button").at(3).simulate("click");
|
||||
expect(mockDevice.home)
|
||||
.toHaveBeenCalledWith({ axis: "all", speed: 100 });
|
||||
});
|
||||
|
||||
it("takes photo", () => {
|
||||
const jogButtons = mount(<JogButtons {...jogButtonProps()} />);
|
||||
const jogButtons =mount<>(<JogButtons {...jogButtonProps()} />);
|
||||
jogButtons.find("button").at(0).simulate("click");
|
||||
expect(mockDevice.takePhoto).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("has unswapped xy jog buttons", () => {
|
||||
const jogButtons = mount(<JogButtons {...jogButtonProps()} />);
|
||||
const jogButtons =mount<>(<JogButtons {...jogButtonProps()} />);
|
||||
const button = jogButtons.find("button").at(6);
|
||||
expect(button.props().title).toBe("move x axis (100)");
|
||||
button.simulate("click");
|
||||
|
@ -82,7 +82,7 @@ describe("<JogButtons/>", function () {
|
|||
const p = jogButtonProps();
|
||||
(p.stepSize as number | undefined) = undefined;
|
||||
p.xySwap = true;
|
||||
const jogButtons = mount(<JogButtons {...p} />);
|
||||
const jogButtons =mount<>(<JogButtons {...p} />);
|
||||
const button = jogButtons.find("button").at(6);
|
||||
expect(button.props().title).toBe("move y axis (100)");
|
||||
button.simulate("click");
|
||||
|
|
|
@ -43,7 +43,7 @@ describe("<Move />", () => {
|
|||
}
|
||||
|
||||
it("has default elements", () => {
|
||||
const wrapper = mount(<Move {...fakeProps()} />);
|
||||
const wrapper =mount<>(<Move {...fakeProps()} />);
|
||||
const txt = wrapper.text().toLowerCase();
|
||||
["move amount (mm)", "110100100010000", "x axisy axisz axis", "motor", "go"]
|
||||
.map(string => expect(txt).toContain(string));
|
||||
|
@ -52,7 +52,7 @@ describe("<Move />", () => {
|
|||
it("has only raw encoder data display", () => {
|
||||
const p = fakeProps();
|
||||
mockConfig.raw_encoders = true;
|
||||
const wrapper = mount(<Move {...p} />);
|
||||
const wrapper =mount<>(<Move {...p} />);
|
||||
const txt = wrapper.text().toLowerCase();
|
||||
expect(txt).toContain("raw");
|
||||
expect(txt).not.toContain("scaled");
|
||||
|
@ -62,14 +62,14 @@ describe("<Move />", () => {
|
|||
const p = fakeProps();
|
||||
mockConfig.raw_encoders = true;
|
||||
mockConfig.scaled_encoders = true;
|
||||
const wrapper = mount(<Move {...p} />);
|
||||
const wrapper =mount<>(<Move {...p} />);
|
||||
const txt = wrapper.text().toLowerCase();
|
||||
expect(txt).toContain("raw");
|
||||
expect(txt).toContain("scaled");
|
||||
});
|
||||
|
||||
it("toggle: invert jog button", () => {
|
||||
const wrapper = mount(<Move {...fakeProps()} />);
|
||||
const wrapper =mount<>(<Move {...fakeProps()} />);
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = wrapper.instance() as any;
|
||||
instance.toggle(BooleanSetting.xy_swap)();
|
||||
|
@ -78,7 +78,7 @@ describe("<Move />", () => {
|
|||
|
||||
it("changes step size", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<Move {...p} />);
|
||||
const wrapper =mount<>(<Move {...p} />);
|
||||
clickButton(wrapper, 0, "1");
|
||||
expect(p.dispatch).toHaveBeenCalledWith({
|
||||
type: Actions.CHANGE_STEP_SIZE,
|
||||
|
|
|
@ -9,7 +9,7 @@ describe("<ToggleButton/>", function () {
|
|||
|
||||
it("calls toggle action", () => {
|
||||
const toggle = jest.fn();
|
||||
const toggleButton = mount(<ToggleButton
|
||||
const toggleButton =mount<>(<ToggleButton
|
||||
toggleValue={0}
|
||||
toggleAction={() => toggle()} />);
|
||||
toggleButton.simulate("click");
|
||||
|
@ -17,21 +17,21 @@ describe("<ToggleButton/>", function () {
|
|||
});
|
||||
|
||||
it("displays no", () => {
|
||||
const toggleButton = mount(<ToggleButton
|
||||
const toggleButton =mount<>(<ToggleButton
|
||||
toggleValue={0}
|
||||
toggleAction={jest.fn()} />);
|
||||
expect(toggleButton.text()).toBe("no");
|
||||
});
|
||||
|
||||
it("displays yes", () => {
|
||||
const toggleButton = mount(<ToggleButton
|
||||
const toggleButton =mount<>(<ToggleButton
|
||||
toggleValue={1}
|
||||
toggleAction={jest.fn()} />);
|
||||
expect(toggleButton.text()).toBe("yes");
|
||||
});
|
||||
|
||||
it("displays off", () => {
|
||||
const toggleButton = mount(<ToggleButton
|
||||
const toggleButton =mount<>(<ToggleButton
|
||||
toggleValue={0}
|
||||
toggleAction={jest.fn()}
|
||||
customText={{ textFalse: "off", textTrue: "on" }} />);
|
||||
|
@ -39,7 +39,7 @@ describe("<ToggleButton/>", function () {
|
|||
});
|
||||
|
||||
it("displays on", () => {
|
||||
const toggleButton = mount(<ToggleButton
|
||||
const toggleButton =mount<>(<ToggleButton
|
||||
toggleValue={1}
|
||||
toggleAction={jest.fn()}
|
||||
customText={{ textFalse: "off", textTrue: "on" }} />);
|
||||
|
@ -47,7 +47,7 @@ describe("<ToggleButton/>", function () {
|
|||
});
|
||||
|
||||
it("displays 🚫", () => {
|
||||
const toggleButton = mount(<ToggleButton
|
||||
const toggleButton =mount<>(<ToggleButton
|
||||
toggleValue={undefined}
|
||||
toggleAction={jest.fn()}
|
||||
customText={{ textFalse: "off", textTrue: "on" }} />);
|
||||
|
|
|
@ -27,7 +27,7 @@ describe("<Peripherals />", () => {
|
|||
}
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<Peripherals {...fakeProps()} />);
|
||||
const wrapper =mount<>(<Peripherals {...fakeProps()} />);
|
||||
["Peripherals", "Edit", "Save", "Fake Pin", "1"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
const saveButton = wrapper.find("button").at(1);
|
||||
|
@ -36,17 +36,17 @@ describe("<Peripherals />", () => {
|
|||
});
|
||||
|
||||
it("isEditing", () => {
|
||||
const wrapper = mount(<Peripherals {...fakeProps()} />);
|
||||
expect(wrapper.state().isEditing).toBeFalsy();
|
||||
const wrapper =mount<>(<Peripherals {...fakeProps()} />);
|
||||
expect(wrapper.instance().state.isEditing).toBeFalsy();
|
||||
clickButton(wrapper, 0, "edit");
|
||||
expect(wrapper.state().isEditing).toBeTruthy();
|
||||
expect(wrapper.instance().state.isEditing).toBeTruthy();
|
||||
});
|
||||
|
||||
function attemptSave(num: number, errorString: string) {
|
||||
const p = fakeProps();
|
||||
p.peripherals[0].body.pin = num;
|
||||
p.peripherals[0].specialStatus = SpecialStatus.DIRTY;
|
||||
const wrapper = mount(<Peripherals {...p} />);
|
||||
const wrapper =mount<>(<Peripherals {...p} />);
|
||||
clickButton(wrapper, 1, "save", { partial_match: true });
|
||||
expect(error).toHaveBeenLastCalledWith(errorString);
|
||||
}
|
||||
|
@ -63,14 +63,14 @@ describe("<Peripherals />", () => {
|
|||
const p = fakeProps();
|
||||
p.peripherals[0].body.pin = 1;
|
||||
p.peripherals[0].specialStatus = SpecialStatus.DIRTY;
|
||||
const wrapper = mount(<Peripherals {...p} />);
|
||||
const wrapper =mount<>(<Peripherals {...p} />);
|
||||
clickButton(wrapper, 1, "save", { partial_match: true });
|
||||
expect(p.dispatch).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("adds empty peripheral", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<Peripherals {...p} />);
|
||||
const wrapper =mount<>(<Peripherals {...p} />);
|
||||
wrapper.setState({ isEditing: true });
|
||||
clickButton(wrapper, 2, "");
|
||||
expect(p.dispatch).toHaveBeenCalled();
|
||||
|
@ -78,7 +78,7 @@ describe("<Peripherals />", () => {
|
|||
|
||||
it("adds farmduino peripherals", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<Peripherals {...p} />);
|
||||
const wrapper =mount<>(<Peripherals {...p} />);
|
||||
wrapper.setState({ isEditing: true });
|
||||
clickButton(wrapper, 3, "farmduino");
|
||||
expect(p.dispatch).toHaveBeenCalledTimes(5);
|
||||
|
|
|
@ -29,7 +29,7 @@ describe("<PeripheralForm/>", function () {
|
|||
];
|
||||
|
||||
it("renders a list of editable peripherals, in sorted order", function () {
|
||||
const form = mount(<PeripheralForm dispatch={dispatch}
|
||||
const form =mount<>(<PeripheralForm dispatch={dispatch}
|
||||
peripherals={peripherals} />);
|
||||
const inputs = form.find("input");
|
||||
const buttons = form.find("button");
|
||||
|
|
|
@ -51,7 +51,7 @@ describe("<PeripheralList/>", function () {
|
|||
};
|
||||
|
||||
it("renders a list of peripherals, in sorted order", function () {
|
||||
const wrapper = mount(<PeripheralList dispatch={() => { }}
|
||||
const wrapper =mount<>(<PeripheralList dispatch={() => { }}
|
||||
peripherals={peripherals}
|
||||
pins={pins}
|
||||
disabled={false} />);
|
||||
|
@ -71,7 +71,7 @@ describe("<PeripheralList/>", function () {
|
|||
});
|
||||
|
||||
it("toggles pins", () => {
|
||||
const wrapper = mount(<PeripheralList dispatch={() => { }}
|
||||
const wrapper =mount<>(<PeripheralList dispatch={() => { }}
|
||||
peripherals={peripherals}
|
||||
pins={pins}
|
||||
disabled={false} />);
|
||||
|
@ -84,7 +84,7 @@ describe("<PeripheralList/>", function () {
|
|||
});
|
||||
|
||||
it("pins toggles are disabled", () => {
|
||||
const wrapper = mount(<PeripheralList dispatch={() => { }}
|
||||
const wrapper =mount<>(<PeripheralList dispatch={() => { }}
|
||||
peripherals={peripherals}
|
||||
pins={pins}
|
||||
disabled={true} />);
|
||||
|
|
|
@ -31,7 +31,7 @@ describe("<Sensors />", () => {
|
|||
}
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<Sensors {...fakeProps()} />);
|
||||
const wrapper =mount<>(<Sensors {...fakeProps()} />);
|
||||
["Sensors", "Edit", "Save", "Fake Pin", "1"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
const saveButton = wrapper.find("button").at(1);
|
||||
|
@ -40,10 +40,10 @@ describe("<Sensors />", () => {
|
|||
});
|
||||
|
||||
it("isEditing", () => {
|
||||
const wrapper = mount(<Sensors {...fakeProps()} />);
|
||||
expect(wrapper.state().isEditing).toBeFalsy();
|
||||
const wrapper =mount<>(<Sensors {...fakeProps()} />);
|
||||
expect(wrapper.instance().state.isEditing).toBeFalsy();
|
||||
clickButton(wrapper, 0, "edit");
|
||||
expect(wrapper.state().isEditing).toBeTruthy();
|
||||
expect(wrapper.instance().state.isEditing).toBeTruthy();
|
||||
});
|
||||
|
||||
it("save attempt: pin number too small", () => {
|
||||
|
@ -51,7 +51,7 @@ describe("<Sensors />", () => {
|
|||
p.sensors[0].body.pin = 1;
|
||||
p.sensors[1].body.pin = 1;
|
||||
p.sensors[0].specialStatus = SpecialStatus.DIRTY;
|
||||
const wrapper = mount(<Sensors {...p} />);
|
||||
const wrapper =mount<>(<Sensors {...p} />);
|
||||
clickButton(wrapper, 1, "save", { partial_match: true });
|
||||
expect(error).toHaveBeenLastCalledWith("Pin numbers must be unique.");
|
||||
});
|
||||
|
@ -60,14 +60,14 @@ describe("<Sensors />", () => {
|
|||
const p = fakeProps();
|
||||
p.sensors[0].body.pin = 1;
|
||||
p.sensors[0].specialStatus = SpecialStatus.DIRTY;
|
||||
const wrapper = mount(<Sensors {...p} />);
|
||||
const wrapper =mount<>(<Sensors {...p} />);
|
||||
clickButton(wrapper, 1, "save", { partial_match: true });
|
||||
expect(p.dispatch).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("adds empty sensor", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<Sensors {...p} />);
|
||||
const wrapper =mount<>(<Sensors {...p} />);
|
||||
wrapper.setState({ isEditing: true });
|
||||
clickButton(wrapper, 2, "");
|
||||
expect(p.dispatch).toHaveBeenCalled();
|
||||
|
@ -75,7 +75,7 @@ describe("<Sensors />", () => {
|
|||
|
||||
it("adds stock sensors", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<Sensors {...p} />);
|
||||
const wrapper =mount<>(<Sensors {...p} />);
|
||||
wrapper.setState({ isEditing: true });
|
||||
clickButton(wrapper, 3, "stock sensors");
|
||||
expect(p.dispatch).toHaveBeenCalledTimes(2);
|
||||
|
|
|
@ -47,7 +47,7 @@ describe("<SensorList/>", function () {
|
|||
};
|
||||
|
||||
it("renders a list of sensors, in sorted order", function () {
|
||||
const wrapper = mount(<SensorList {...fakeProps()} />);
|
||||
const wrapper =mount<>(<SensorList {...fakeProps()} />);
|
||||
const labels = wrapper.find("label");
|
||||
const pinNumbers = wrapper.find("p");
|
||||
expect(labels.first().text()).toEqual("GPIO 51");
|
||||
|
@ -73,7 +73,7 @@ describe("<SensorList/>", function () {
|
|||
});
|
||||
|
||||
it("reads pins", () => {
|
||||
const wrapper = mount(<SensorList {...fakeProps()} />);
|
||||
const wrapper =mount<>(<SensorList {...fakeProps()} />);
|
||||
const toggle = wrapper.find("button");
|
||||
toggle.first().simulate("click");
|
||||
expect(mockDevice.send).toHaveBeenCalledWith(expectedPayload(51, 1));
|
||||
|
@ -85,7 +85,7 @@ describe("<SensorList/>", function () {
|
|||
it("pins toggles are disabled", () => {
|
||||
const p = fakeProps();
|
||||
p.disabled = true;
|
||||
const wrapper = mount(<SensorList {...p} />);
|
||||
const wrapper =mount<>(<SensorList {...p} />);
|
||||
const toggle = wrapper.find("button");
|
||||
toggle.first().simulate("click");
|
||||
toggle.last().simulate("click");
|
||||
|
|
|
@ -17,7 +17,7 @@ describe("<Edit/>", () => {
|
|||
|
||||
it("renders the list of feeds", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<Edit {...p} />);
|
||||
const wrapper =mount<>(<Edit {...p} />);
|
||||
[
|
||||
p.feeds[0].body.name,
|
||||
p.feeds[0].body.url,
|
||||
|
@ -29,7 +29,7 @@ describe("<Edit/>", () => {
|
|||
|
||||
it("saves feeds", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<Edit {...p} />);
|
||||
const wrapper =mount<>(<Edit {...p} />);
|
||||
clickButton(wrapper, 1, "save*");
|
||||
expect(p.save).toHaveBeenCalledWith(p.feeds[0]);
|
||||
});
|
||||
|
@ -38,7 +38,7 @@ describe("<Edit/>", () => {
|
|||
const p = fakeProps();
|
||||
p.feeds[0].specialStatus = SpecialStatus.SAVED;
|
||||
p.feeds[1].specialStatus = SpecialStatus.SAVED;
|
||||
const wrapper = mount(<Edit {...p} />);
|
||||
const wrapper =mount<>(<Edit {...p} />);
|
||||
expect(wrapper.find("button").at(1).text()).toEqual("Save");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,22 +13,22 @@ import { clickButton, allButtonText } from "../../../__test_support__/helpers";
|
|||
describe("<WebcamPanel/>", () => {
|
||||
it("toggles form state to edit", () => {
|
||||
const props = { feeds: [], dispatch: jest.fn() };
|
||||
const wrapper = mount(<WebcamPanel {...props} />);
|
||||
expect(wrapper.state().activeMenu).toEqual("show");
|
||||
const wrapper =mount<>(<WebcamPanel {...props} />);
|
||||
expect(wrapper.instance().state.activeMenu).toEqual("show");
|
||||
const text = allButtonText(wrapper);
|
||||
expect(text.toLowerCase()).not.toContain("view");
|
||||
clickButton(wrapper, 0, "edit");
|
||||
expect(wrapper.state().activeMenu).toEqual("edit");
|
||||
expect(wrapper.instance().state.activeMenu).toEqual("edit");
|
||||
});
|
||||
|
||||
it("toggles form state to view", () => {
|
||||
const props = { feeds: [], dispatch: jest.fn() };
|
||||
const wrapper = mount(<WebcamPanel {...props} />);
|
||||
const wrapper =mount<>(<WebcamPanel {...props} />);
|
||||
wrapper.setState({ activeMenu: "edit" });
|
||||
const text = allButtonText(wrapper);
|
||||
expect(text.toLowerCase()).not.toContain("edit");
|
||||
clickButton(wrapper, 2, "view");
|
||||
expect(wrapper.state().activeMenu).toEqual("show");
|
||||
expect(wrapper.instance().state.activeMenu).toEqual("show");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ describe("<Show/>", () => {
|
|||
const feed1 = fakeWebcamFeed();
|
||||
const feed2 = fakeWebcamFeed();
|
||||
const p = props([feed1, feed2]);
|
||||
const el = mount(<Show {...p} />);
|
||||
const el =mount<>(<Show {...p} />);
|
||||
expect(el.text()).toContain(feed1.body.name);
|
||||
el.find(".image-flipper-right").first().simulate("click");
|
||||
el.render();
|
||||
|
@ -19,19 +19,19 @@ describe("<Show/>", () => {
|
|||
|
||||
describe("<IndexIndicator/>", () => {
|
||||
it("renders index indicator: position 1", () => {
|
||||
const wrapper = mount(<IndexIndicator i={0} total={2} />);
|
||||
const wrapper =mount<>(<IndexIndicator i={0} total={2} />);
|
||||
expect(wrapper.find("div").props().style)
|
||||
.toEqual({ left: "calc(-10px + 0 * 50%)", width: "50%" });
|
||||
});
|
||||
|
||||
it("renders index indicator: position 2", () => {
|
||||
const wrapper = mount(<IndexIndicator i={1} total={4} />);
|
||||
const wrapper =mount<>(<IndexIndicator i={1} total={4} />);
|
||||
expect(wrapper.find("div").props().style)
|
||||
.toEqual({ left: "calc(-10px + 1 * 25%)", width: "25%" });
|
||||
});
|
||||
|
||||
it("doesn't render index indicator", () => {
|
||||
const wrapper = mount(<IndexIndicator i={0} total={1} />);
|
||||
const wrapper =mount<>(<IndexIndicator i={0} total={1} />);
|
||||
expect(wrapper.html()).toEqual("<div></div>");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,7 +9,7 @@ import { bot } from "../../../__test_support__/fake_state/bot";
|
|||
describe("BooleanMCUInputGroup", () => {
|
||||
it("triggers callbacks", () => {
|
||||
const dispatch = jest.fn();
|
||||
const el = mount(<BooleanMCUInputGroup
|
||||
const el =mount<>(<BooleanMCUInputGroup
|
||||
sourceFwConfig={(x) => {
|
||||
return { value: bot.hardware.mcu_params[x], consistent: true };
|
||||
}}
|
||||
|
|
|
@ -17,7 +17,7 @@ describe("<DiagnosticDumpRow/>", () => {
|
|||
const dispatch = jest.fn();
|
||||
const diag = fakeDiagnosticDump();
|
||||
diag.body.ticket_identifier = "0000";
|
||||
const el = mount(<DiagnosticDumpRow dispatch={dispatch} diag={diag} />);
|
||||
const el =mount<>(<DiagnosticDumpRow dispatch={dispatch} diag={diag} />);
|
||||
expect(el.text()).toContain("0000");
|
||||
el.find("a").first().simulate("click");
|
||||
expect(jsonDownload).toHaveBeenCalledWith(diag.body, "farmbot_diagnostics_0000.json");
|
||||
|
|
|
@ -7,14 +7,14 @@ import { taggedUser } from "../../../__test_support__/user";
|
|||
describe("<EStopButton />", () => {
|
||||
it("renders", () => {
|
||||
bot.hardware.informational_settings.sync_status = "synced";
|
||||
const wrapper = mount(<EStopButton bot={bot} user={taggedUser} />);
|
||||
const wrapper =mount<>(<EStopButton bot={bot} user={taggedUser} />);
|
||||
expect(wrapper.text()).toEqual("E-STOP");
|
||||
expect(wrapper.find("button").hasClass("red")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("grayed out", () => {
|
||||
bot.hardware.informational_settings.sync_status = undefined;
|
||||
const wrapper = mount(<EStopButton bot={bot} user={taggedUser} />);
|
||||
const wrapper =mount<>(<EStopButton bot={bot} user={taggedUser} />);
|
||||
expect(wrapper.text()).toEqual("E-STOP");
|
||||
expect(wrapper.find("button").hasClass("gray")).toBeTruthy();
|
||||
});
|
||||
|
@ -22,7 +22,7 @@ describe("<EStopButton />", () => {
|
|||
it("locked", () => {
|
||||
bot.hardware.informational_settings.sync_status = "synced";
|
||||
bot.hardware.informational_settings.locked = true;
|
||||
const wrapper = mount(<EStopButton bot={bot} user={taggedUser} />);
|
||||
const wrapper =mount<>(<EStopButton bot={bot} user={taggedUser} />);
|
||||
expect(wrapper.text()).toEqual("UNLOCK");
|
||||
expect(wrapper.find("button").hasClass("yellow")).toBeTruthy();
|
||||
});
|
||||
|
|
|
@ -40,7 +40,7 @@ describe("<FarmbotOsSettings/>", () => {
|
|||
};
|
||||
|
||||
it("renders settings", () => {
|
||||
const osSettings = mount(<FarmbotOsSettings {...fakeProps()} />);
|
||||
const osSettings =mount<>(<FarmbotOsSettings {...fakeProps()} />);
|
||||
expect(osSettings.find("input").length).toBe(1);
|
||||
expect(osSettings.find("button").length).toBe(6);
|
||||
["NAME", "TIME ZONE", "LAST SEEN", "FARMBOT OS", "CAMERA", "FIRMWARE"]
|
||||
|
@ -49,19 +49,19 @@ describe("<FarmbotOsSettings/>", () => {
|
|||
|
||||
it("fetches OS release notes", async () => {
|
||||
mockReleaseNoteData = { data: "intro\n\n# v6\n\n* note" };
|
||||
const osSettings = await mount(<FarmbotOsSettings {...fakeProps()} />);
|
||||
const osSettings = awaitmount<>(<FarmbotOsSettings {...fakeProps()} />);
|
||||
await expect(axios.get).toHaveBeenCalledWith(
|
||||
expect.stringContaining("RELEASE_NOTES.md"));
|
||||
expect(osSettings.state().osReleaseNotes)
|
||||
expect(osSettings.instance().state.osReleaseNotes)
|
||||
.toEqual("# FarmBot OS v6\n* note");
|
||||
});
|
||||
|
||||
it("doesn't fetch OS release notes", async () => {
|
||||
mockReleaseNoteData = { data: "empty notes" };
|
||||
const osSettings = await mount(<FarmbotOsSettings {...fakeProps()} />);
|
||||
const osSettings = awaitmount<>(<FarmbotOsSettings {...fakeProps()} />);
|
||||
await expect(axios.get).toHaveBeenCalledWith(
|
||||
expect.stringContaining("RELEASE_NOTES.md"));
|
||||
expect(osSettings.state().osReleaseNotes)
|
||||
expect(osSettings.instance().state.osReleaseNotes)
|
||||
.toEqual("Could not get release notes.");
|
||||
});
|
||||
|
||||
|
@ -94,7 +94,7 @@ describe("<FbosDetails />", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<FbosDetails {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FbosDetails {...fakeProps()} />);
|
||||
["Environment: ---",
|
||||
"Commit: ---",
|
||||
"Target: ---",
|
||||
|
|
|
@ -31,7 +31,7 @@ describe("<HardwareSettings />", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<HardwareSettings {...fakeProps()} />);
|
||||
const wrapper =mount<>(<HardwareSettings {...fakeProps()} />);
|
||||
["expand all", "x axis", "motors"].map(string =>
|
||||
expect(wrapper.text().toLowerCase()).toContain(string));
|
||||
});
|
||||
|
@ -43,7 +43,7 @@ describe("<HardwareSettings />", () => {
|
|||
type: string,
|
||||
payload: boolean | string) {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<HardwareSettings {...p} />);
|
||||
const wrapper =mount<>(<HardwareSettings {...p} />);
|
||||
clickButton(wrapper, buttonIndex, buttonText, {
|
||||
button_tag: buttonElement, partial_match: true
|
||||
});
|
||||
|
@ -82,7 +82,7 @@ describe("<HardwareSettings />", () => {
|
|||
describe("<FwParamExportMenu />", () => {
|
||||
it("lists all params", () => {
|
||||
const config = fakeFirmwareConfig().body;
|
||||
const wrapper = mount(<FwParamExportMenu firmwareConfig={config} />);
|
||||
const wrapper =mount<>(<FwParamExportMenu firmwareConfig={config} />);
|
||||
expect(wrapper.text()).toContain("movement_max_spd_");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,13 +5,13 @@ import { mount } from "enzyme";
|
|||
describe("<LockableButton/>", () => {
|
||||
it("does not trigger callback when clicked and disabled", () => {
|
||||
const fakeCB = jest.fn();
|
||||
const btn = mount(<LockableButton disabled={true} onClick={fakeCB} />);
|
||||
const btn =mount<>(<LockableButton disabled={true} onClick={fakeCB} />);
|
||||
btn.simulate("click");
|
||||
expect(fakeCB).not.toHaveBeenCalled();
|
||||
});
|
||||
it("does trigger callback when clicked and enabled", () => {
|
||||
const fakeCB = jest.fn();
|
||||
const btn = mount(<LockableButton disabled={false} onClick={fakeCB} />);
|
||||
const btn =mount<>(<LockableButton disabled={false} onClick={fakeCB} />);
|
||||
btn.simulate("click");
|
||||
expect(fakeCB).toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
@ -51,7 +51,7 @@ describe("<PinBindings/>", () => {
|
|||
}
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<PinBindings {...fakeProps()} />);
|
||||
const wrapper =mount<>(<PinBindings {...fakeProps()} />);
|
||||
["pin bindings", "pin number", "none", "bind"].map(string =>
|
||||
expect(wrapper.text().toLowerCase()).toContain(string));
|
||||
["pi gpio 10", "sequence 1", "pi gpio 11", "sequence 2"].map(string =>
|
||||
|
@ -64,7 +64,7 @@ describe("<PinBindings/>", () => {
|
|||
it("unregisters pin: bot", () => {
|
||||
const p = fakeProps();
|
||||
p.dispatch = jest.fn(x => x(jest.fn()));
|
||||
const wrapper = mount(<PinBindings {...p} />);
|
||||
const wrapper =mount<>(<PinBindings {...p} />);
|
||||
const buttons = wrapper.find("button");
|
||||
buttons.first().simulate("click");
|
||||
expect(mockDevice.unregisterGpio).toHaveBeenCalledWith({
|
||||
|
@ -78,7 +78,7 @@ describe("<PinBindings/>", () => {
|
|||
s.body.id = 1;
|
||||
p.resources = buildResourceIndex([fakePinBinding(), s]).index;
|
||||
p.shouldDisplay = () => true;
|
||||
const wrapper = mount(<PinBindings {...p} />);
|
||||
const wrapper =mount<>(<PinBindings {...p} />);
|
||||
const buttons = wrapper.find("button");
|
||||
buttons.first().simulate("click");
|
||||
expect(mockDevice.unregisterGpio).not.toHaveBeenCalled();
|
||||
|
@ -88,7 +88,7 @@ describe("<PinBindings/>", () => {
|
|||
it("registers pin: bot", () => {
|
||||
const p = fakeProps();
|
||||
p.dispatch = jest.fn(x => x(jest.fn()));
|
||||
const wrapper = mount(<PinBindings {...p} />);
|
||||
const wrapper =mount<>(<PinBindings {...p} />);
|
||||
const buttons = wrapper.find("button");
|
||||
expect(buttons.last().text()).toEqual("BIND");
|
||||
wrapper.setState({ pinNumberInput: 1, sequenceIdInput: 2 });
|
||||
|
@ -102,7 +102,7 @@ describe("<PinBindings/>", () => {
|
|||
const p = fakeProps();
|
||||
p.dispatch = jest.fn();
|
||||
p.shouldDisplay = () => true;
|
||||
const wrapper = mount(<PinBindings {...p} />);
|
||||
const wrapper =mount<>(<PinBindings {...p} />);
|
||||
const buttons = wrapper.find("button");
|
||||
expect(buttons.last().text()).toEqual("BIND");
|
||||
wrapper.setState({ pinNumberInput: 1, sequenceIdInput: 2 });
|
||||
|
@ -117,24 +117,24 @@ describe("<PinBindings/>", () => {
|
|||
const p = fakeProps();
|
||||
const s = p.resources.references[p.resources.byKind.Sequence[0]];
|
||||
const id = s && s.body.id;
|
||||
const wrapper = mount(<PinBindings {...p} />);
|
||||
expect(wrapper.state().sequenceIdInput).toEqual(undefined);
|
||||
const wrapper =mount<>(<PinBindings {...p} />);
|
||||
expect(wrapper.instance().state.sequenceIdInput).toEqual(undefined);
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = wrapper.instance() as any;
|
||||
instance.changeSelection({ label: "label", value: id });
|
||||
expect(wrapper.state().sequenceIdInput).toEqual(id);
|
||||
expect(wrapper.instance().state.sequenceIdInput).toEqual(id);
|
||||
});
|
||||
|
||||
it("sets pin", () => {
|
||||
const wrapper = mount(<PinBindings {...fakeProps()} />);
|
||||
expect(wrapper.state().pinNumberInput).toEqual(undefined);
|
||||
const wrapper =mount<>(<PinBindings {...fakeProps()} />);
|
||||
expect(wrapper.instance().state.pinNumberInput).toEqual(undefined);
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = wrapper.instance() as any;
|
||||
instance.setSelectedPin(10);
|
||||
expect(wrapper.state().pinNumberInput).toEqual(undefined);
|
||||
expect(wrapper.instance().state.pinNumberInput).toEqual(undefined);
|
||||
instance.setSelectedPin(99);
|
||||
expect(wrapper.state().pinNumberInput).toEqual(undefined);
|
||||
expect(wrapper.instance().state.pinNumberInput).toEqual(undefined);
|
||||
instance.setSelectedPin(5);
|
||||
expect(wrapper.state().pinNumberInput).toEqual(5);
|
||||
expect(wrapper.instance().state.pinNumberInput).toEqual(5);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ describe("<PinGuardMCUInputGroup/>", () => {
|
|||
|
||||
it("calls toggle action ", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<PinGuardMCUInputGroup {...p} />);
|
||||
const wrapper =mount<>(<PinGuardMCUInputGroup {...p} />);
|
||||
wrapper.find("button").simulate("click");
|
||||
expect(settingToggle).toHaveBeenCalledWith("pin_guard_1_active_state",
|
||||
expect.any(Function));
|
||||
|
|
|
@ -13,17 +13,17 @@ describe("<RpiGpioDiagram />", () => {
|
|||
}
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<RpiGpioDiagram {...fakeProps() } />);
|
||||
const wrapper =mount<>(<RpiGpioDiagram {...fakeProps()} />);
|
||||
expect(wrapper.find("rect").length).toEqual(42);
|
||||
});
|
||||
|
||||
it("pin hover", () => {
|
||||
const wrapper = mount(<RpiGpioDiagram {...fakeProps() } />);
|
||||
const wrapper =mount<>(<RpiGpioDiagram {...fakeProps()} />);
|
||||
wrapper.find("rect").at(5).simulate("mouseEnter");
|
||||
expect(wrapper.state().hoveredPin).toEqual("GND");
|
||||
expect(wrapper.instance().state.hoveredPin).toEqual("GND");
|
||||
const pinToHover = wrapper.find("rect").at(6);
|
||||
pinToHover.simulate("mouseEnter");
|
||||
expect(wrapper.state().hoveredPin).toEqual(17);
|
||||
expect(wrapper.instance().state.hoveredPin).toEqual(17);
|
||||
expect(wrapper.find("rect").at(6).props().fill).toEqual(Color.white);
|
||||
pinToHover.simulate("mouseLeave");
|
||||
expect(pinToHover.props().fill).toEqual(Color.green);
|
||||
|
@ -32,7 +32,7 @@ describe("<RpiGpioDiagram />", () => {
|
|||
|
||||
it("pin click", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<RpiGpioDiagram {...p} />);
|
||||
const wrapper =mount<>(<RpiGpioDiagram {...p} />);
|
||||
wrapper.find("rect").at(6).simulate("click");
|
||||
expect(p.setSelectedPin).toHaveBeenCalledWith(17);
|
||||
jest.clearAllMocks();
|
||||
|
|
|
@ -25,14 +25,14 @@ describe("<AutoSyncRow/>", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<AutoSyncRow {...fakeProps() } />);
|
||||
const wrapper =mount<>(<AutoSyncRow {...fakeProps() } />);
|
||||
["AUTO SYNC", Content.AUTO_SYNC]
|
||||
.map(string => expect(wrapper.text()).toContain(string));
|
||||
});
|
||||
|
||||
it("toggles", () => {
|
||||
bot.hardware.configuration.auto_sync = true;
|
||||
const wrapper = mount(<AutoSyncRow {...fakeProps() } />);
|
||||
const wrapper =mount<>(<AutoSyncRow {...fakeProps() } />);
|
||||
wrapper.find("button").simulate("click");
|
||||
expect(mockDevice.updateConfig)
|
||||
.toHaveBeenCalledWith({ auto_sync: false });
|
||||
|
|
|
@ -27,13 +27,13 @@ describe("<AutoUpdateRow/>", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<AutoUpdateRow {...fakeProps() } />);
|
||||
const wrapper =mount<>(<AutoUpdateRow {...fakeProps() } />);
|
||||
expect(wrapper.text().toLowerCase()).toContain("auto update");
|
||||
});
|
||||
|
||||
it("toggles auto-update on", () => {
|
||||
bot.hardware.configuration.os_auto_update = 0;
|
||||
const wrapper = mount(<AutoUpdateRow {...fakeProps() } />);
|
||||
const wrapper =mount<>(<AutoUpdateRow {...fakeProps() } />);
|
||||
wrapper.find("button").first().simulate("click");
|
||||
expect(mockDevice.updateConfig)
|
||||
.toHaveBeenCalledWith({ os_auto_update: 1 });
|
||||
|
@ -41,7 +41,7 @@ describe("<AutoUpdateRow/>", () => {
|
|||
|
||||
it("toggles auto-update off", () => {
|
||||
bot.hardware.configuration.os_auto_update = 1;
|
||||
const wrapper = mount(<AutoUpdateRow {...fakeProps() } />);
|
||||
const wrapper =mount<>(<AutoUpdateRow {...fakeProps() } />);
|
||||
wrapper.find("button").first().simulate("click");
|
||||
expect(mockDevice.updateConfig)
|
||||
.toHaveBeenCalledWith({ os_auto_update: 0 });
|
||||
|
|
|
@ -33,28 +33,28 @@ describe("<BoardType/>", () => {
|
|||
it("Farmduino", () => {
|
||||
const p = fakeProps();
|
||||
p.firmwareVersion = "5.0.3.F";
|
||||
const wrapper = mount(<BoardType {...p} />);
|
||||
const wrapper =mount<>(<BoardType {...p} />);
|
||||
expect(wrapper.text()).toContain("Farmduino");
|
||||
});
|
||||
|
||||
it("Farmduino k1.4", () => {
|
||||
const p = fakeProps();
|
||||
p.firmwareVersion = "5.0.3.G";
|
||||
const wrapper = mount(<BoardType {...p} />);
|
||||
const wrapper =mount<>(<BoardType {...p} />);
|
||||
expect(wrapper.text()).toContain("1.4");
|
||||
});
|
||||
|
||||
it("Arduino/RAMPS", () => {
|
||||
const p = fakeProps();
|
||||
p.firmwareVersion = "5.0.3.R";
|
||||
const wrapper = mount(<BoardType {...p} />);
|
||||
const wrapper =mount<>(<BoardType {...p} />);
|
||||
expect(wrapper.text()).toContain("Arduino/RAMPS");
|
||||
});
|
||||
|
||||
it("Undefined", () => {
|
||||
const p = fakeProps();
|
||||
p.firmwareVersion = undefined;
|
||||
const wrapper = mount(<BoardType {...p} />);
|
||||
const wrapper =mount<>(<BoardType {...p} />);
|
||||
expect(wrapper.text()).toContain("None");
|
||||
});
|
||||
|
||||
|
@ -69,7 +69,7 @@ describe("<BoardType/>", () => {
|
|||
it("Stubbed", () => {
|
||||
const p = fakeProps();
|
||||
p.firmwareVersion = "STUBFW";
|
||||
const wrapper = mount(<BoardType {...p} />);
|
||||
const wrapper =mount<>(<BoardType {...p} />);
|
||||
expect(wrapper.text()).toContain("None");
|
||||
});
|
||||
|
||||
|
@ -77,7 +77,7 @@ describe("<BoardType/>", () => {
|
|||
const p = fakeProps();
|
||||
p.firmwareVersion = "Arduino Disconnected!";
|
||||
p.sourceFbosConfig = () => ({ value: "farmduino", consistent: false });
|
||||
const wrapper = mount(<BoardType {...p} />);
|
||||
const wrapper =mount<>(<BoardType {...p} />);
|
||||
expect(wrapper.text()).toContain("Farmduino");
|
||||
});
|
||||
|
||||
|
|
|
@ -26,14 +26,14 @@ describe("<CameraSelection/>", () => {
|
|||
};
|
||||
|
||||
it("doesn't render camera", () => {
|
||||
const cameraSelection = mount(<CameraSelection {...fakeProps()} />);
|
||||
const cameraSelection =mount<>(<CameraSelection {...fakeProps()} />);
|
||||
expect(cameraSelection.find("button").text()).toEqual("USB Camera");
|
||||
});
|
||||
|
||||
it("renders camera", () => {
|
||||
const p = fakeProps();
|
||||
p.env = { "camera": "\"RPI\"" };
|
||||
const cameraSelection = mount(<CameraSelection {...p} />);
|
||||
const cameraSelection =mount<>(<CameraSelection {...p} />);
|
||||
expect(cameraSelection.find("button").text()).toEqual("Raspberry Pi Camera");
|
||||
});
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ describe("<ChangeOwnershipForm/>", () => {
|
|||
beforeEach(() => API.setBaseUrl("https://my.farm.bot"));
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<ChangeOwnershipForm />);
|
||||
const wrapper =mount<>(<ChangeOwnershipForm />);
|
||||
["email", "password", "server"]
|
||||
.map(string => expect(wrapper.text().toLowerCase()).toContain(string));
|
||||
});
|
||||
|
||||
it("submits", () => {
|
||||
const wrapper = mount(<ChangeOwnershipForm />);
|
||||
const wrapper =mount<>(<ChangeOwnershipForm />);
|
||||
wrapper.find("button").simulate("click");
|
||||
expect(transferOwnership).toHaveBeenCalledWith({
|
||||
device: mockDevice,
|
||||
|
|
|
@ -56,7 +56,7 @@ describe("<FbosDetails/>", () => {
|
|||
|
||||
it("toggles os beta opt in setting on", () => {
|
||||
bot.hardware.configuration.beta_opt_in = false;
|
||||
const wrapper = mount(<FbosDetails {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FbosDetails {...fakeProps()} />);
|
||||
window.confirm = jest.fn();
|
||||
wrapper.find("button").simulate("click");
|
||||
expect(window.confirm).toHaveBeenCalledWith(
|
||||
|
@ -70,7 +70,7 @@ describe("<FbosDetails/>", () => {
|
|||
|
||||
it("toggles os beta opt in setting off", () => {
|
||||
bot.hardware.configuration.beta_opt_in = true;
|
||||
const wrapper = mount(<FbosDetails {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FbosDetails {...fakeProps()} />);
|
||||
window.confirm = () => false;
|
||||
wrapper.find("button").simulate("click");
|
||||
expect(mockDevice.updateConfig)
|
||||
|
|
|
@ -23,12 +23,12 @@ describe("<LastSeen/>", () => {
|
|||
it("blinks when loading", () => {
|
||||
const p = props();
|
||||
p.device.specialStatus = SpecialStatus.SAVING;
|
||||
const wrapper = mount(<LastSeen {...p} />);
|
||||
const wrapper =mount<>(<LastSeen {...p} />);
|
||||
expect(wrapper.text()).toContain("Loading");
|
||||
});
|
||||
|
||||
it("tells you the device has never been seen", () => {
|
||||
const wrapper = mount(<LastSeen {...props() } />);
|
||||
const wrapper =mount<>(<LastSeen {...props() } />);
|
||||
expect(wrapper.text()).toContain("network connectivity issue");
|
||||
});
|
||||
|
||||
|
@ -36,7 +36,7 @@ describe("<LastSeen/>", () => {
|
|||
const p = props();
|
||||
p.device.body.last_saw_api = "2017-08-07T19:40:01.487Z";
|
||||
p.botToMqttLastSeen = "";
|
||||
const wrapper = mount(<LastSeen {...p} />);
|
||||
const wrapper =mount<>(<LastSeen {...p} />);
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = wrapper.instance() as any;
|
||||
expect(instance.lastSeen).toEqual("2017-08-07T19:40:01.487Z");
|
||||
|
@ -46,7 +46,7 @@ describe("<LastSeen/>", () => {
|
|||
const p = props();
|
||||
p.device.body.last_saw_api = "2017-08-07T19:40:01.487Z";
|
||||
p.botToMqttLastSeen = "2017-08-07T20:40:01.487Z";
|
||||
const wrapper = mount(<LastSeen {...p} />);
|
||||
const wrapper =mount<>(<LastSeen {...p} />);
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = wrapper.instance() as any;
|
||||
expect(instance.lastSeen).toEqual("2017-08-07T20:40:01.487Z");
|
||||
|
@ -54,7 +54,7 @@ describe("<LastSeen/>", () => {
|
|||
|
||||
it("handles a click", () => {
|
||||
const p = props();
|
||||
const wrapper = mount(<LastSeen {...p} />);
|
||||
const wrapper =mount<>(<LastSeen {...p} />);
|
||||
wrapper.find("i").simulate("click");
|
||||
expect(p.onClick).toHaveBeenCalled();
|
||||
});
|
||||
|
|
|
@ -33,7 +33,7 @@ describe("<OsUpdateButton/>", () => {
|
|||
|
||||
it("renders buttons: not connected", () => {
|
||||
bot.currentOSVersion = undefined;
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
expect(buttons.find("button").length).toBe(1);
|
||||
const autoUpdate = buttons.find("button").first();
|
||||
expect(autoUpdate.hasClass("yellow")).toBeTruthy();
|
||||
|
@ -42,7 +42,7 @@ describe("<OsUpdateButton/>", () => {
|
|||
});
|
||||
it("renders buttons: not connected to bot", () => {
|
||||
bot.hardware.informational_settings.controller_version = undefined;
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
expect(buttons.find("button").length).toBe(1);
|
||||
const autoUpdate = buttons.find("button").first();
|
||||
expect(autoUpdate.hasClass("yellow")).toBeTruthy();
|
||||
|
@ -51,7 +51,7 @@ describe("<OsUpdateButton/>", () => {
|
|||
});
|
||||
it("renders buttons: no beta releases", () => {
|
||||
bot.hardware.configuration.beta_opt_in = true;
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
expect(buttons.find("button").length).toBe(1);
|
||||
const autoUpdate = buttons.find("button").first();
|
||||
expect(autoUpdate.hasClass("yellow")).toBeTruthy();
|
||||
|
@ -60,21 +60,21 @@ describe("<OsUpdateButton/>", () => {
|
|||
});
|
||||
it("up to date", () => {
|
||||
bot.hardware.informational_settings.controller_version = "3.1.6";
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
const osUpdateButton = buttons.find("button").last();
|
||||
expect(osUpdateButton.text()).toBe("UP TO DATE");
|
||||
expect(osUpdateButton.props().title).toBe("3.1.6");
|
||||
});
|
||||
it("up to date: newer", () => {
|
||||
bot.hardware.informational_settings.controller_version = "5.0.0";
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
const osUpdateButton = buttons.find("button").last();
|
||||
expect(osUpdateButton.text()).toBe("UP TO DATE");
|
||||
expect(osUpdateButton.props().title).toBe("3.1.6");
|
||||
});
|
||||
it("update available", () => {
|
||||
bot.hardware.informational_settings.controller_version = "3.1.5";
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
const osUpdateButton = buttons.find("button").last();
|
||||
expect(osUpdateButton.text()).toBe("UPDATE");
|
||||
expect(osUpdateButton.props().title).toBe("3.1.6");
|
||||
|
@ -83,7 +83,7 @@ describe("<OsUpdateButton/>", () => {
|
|||
bot.hardware.informational_settings.controller_version = "3.1.5";
|
||||
bot.hardware.configuration.beta_opt_in = true;
|
||||
bot.currentBetaOSVersion = "5.0.0-beta";
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
const osUpdateButton = buttons.find("button").last();
|
||||
expect(osUpdateButton.text()).toBe("UPDATE");
|
||||
expect(osUpdateButton.props().title).toBe("5.0.0-beta");
|
||||
|
@ -94,13 +94,13 @@ describe("<OsUpdateButton/>", () => {
|
|||
bot.hardware.configuration.beta_opt_in = true;
|
||||
bot.currentBetaOSVersion = "5.0.0-beta";
|
||||
bot.currentBetaOSCommit = "new commit";
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
const osUpdateButton = buttons.find("button").last();
|
||||
expect(osUpdateButton.text()).toBe("UPDATE");
|
||||
expect(osUpdateButton.props().title).toBe("5.0.0-beta");
|
||||
});
|
||||
it("calls checkUpdates", () => {
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
const osUpdateButton = buttons.find("button").last();
|
||||
osUpdateButton.simulate("click");
|
||||
expect(mockDevice.checkUpdates).toHaveBeenCalledTimes(1);
|
||||
|
@ -111,7 +111,7 @@ describe("<OsUpdateButton/>", () => {
|
|||
bot.hardware.jobs = {
|
||||
"FBOS_OTA": { status: "working", bytes: progress, unit: "bytes" }
|
||||
};
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
const osUpdateButton = buttons.find("button").last();
|
||||
expect(osUpdateButton.text()).toBe(text);
|
||||
});
|
||||
|
@ -124,7 +124,7 @@ describe("<OsUpdateButton/>", () => {
|
|||
bot.hardware.jobs = {
|
||||
"FBOS_OTA": { status: "working", percent: 10, unit: "percent" }
|
||||
};
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
const osUpdateButton = buttons.find("button").last();
|
||||
expect(osUpdateButton.text()).toBe("10%");
|
||||
});
|
||||
|
@ -133,7 +133,7 @@ describe("<OsUpdateButton/>", () => {
|
|||
"FBOS_OTA": { status: "complete", percent: 100, unit: "percent" }
|
||||
};
|
||||
bot.hardware.informational_settings.controller_version = "3.1.6";
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
const osUpdateButton = buttons.find("button").last();
|
||||
expect(osUpdateButton.text()).toBe("UP TO DATE");
|
||||
});
|
||||
|
@ -142,7 +142,7 @@ describe("<OsUpdateButton/>", () => {
|
|||
"FBOS_OTA": { status: "error", percent: 10, unit: "percent" }
|
||||
};
|
||||
bot.hardware.informational_settings.controller_version = "3.1.5";
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
const osUpdateButton = buttons.find("button").last();
|
||||
expect(osUpdateButton.text()).toBe("UPDATE");
|
||||
});
|
||||
|
@ -150,7 +150,7 @@ describe("<OsUpdateButton/>", () => {
|
|||
bot.hardware.jobs = {
|
||||
"FBOS_OTA": { status: "working", percent: 10, unit: "percent" }
|
||||
};
|
||||
const buttons = mount(<OsUpdateButton {...fakeProps()} />);
|
||||
const buttons =mount<>(<OsUpdateButton {...fakeProps()} />);
|
||||
const osUpdateButton = buttons.find("button").last();
|
||||
osUpdateButton.simulate("click");
|
||||
expect(mockDevice.checkUpdates).not.toHaveBeenCalled();
|
||||
|
|
|
@ -29,7 +29,7 @@ describe("<PowerAndReset/>", () => {
|
|||
it("open", () => {
|
||||
const p = fakeProps();
|
||||
p.controlPanelState.power_and_reset = true;
|
||||
const wrapper = mount(<PowerAndReset {...p} />);
|
||||
const wrapper =mount<>(<PowerAndReset {...p} />);
|
||||
["Power and Reset", "Restart", "Shutdown", "Factory Reset",
|
||||
"Automatic Factory Reset", "Connection Attempt Period"]
|
||||
.map(string => expect(wrapper.text().toLowerCase())
|
||||
|
@ -39,7 +39,7 @@ describe("<PowerAndReset/>", () => {
|
|||
it("closed", () => {
|
||||
const p = fakeProps();
|
||||
p.controlPanelState.power_and_reset = false;
|
||||
const wrapper = mount(<PowerAndReset {...p} />);
|
||||
const wrapper =mount<>(<PowerAndReset {...p} />);
|
||||
expect(wrapper.text().toLowerCase())
|
||||
.toContain("Power and Reset".toLowerCase());
|
||||
expect(wrapper.text().toLowerCase())
|
||||
|
@ -50,7 +50,7 @@ describe("<PowerAndReset/>", () => {
|
|||
bot.hardware.configuration.disable_factory_reset = true;
|
||||
const p = fakeProps();
|
||||
p.controlPanelState.power_and_reset = true;
|
||||
const wrapper = mount(<PowerAndReset {...p} />);
|
||||
const wrapper =mount<>(<PowerAndReset {...p} />);
|
||||
expect(wrapper.find("input").last().props().disabled).toBeTruthy();
|
||||
expect(wrapper.find("label").last().props().style)
|
||||
.toEqual({ color: "grey" });
|
||||
|
@ -60,7 +60,7 @@ describe("<PowerAndReset/>", () => {
|
|||
bot.hardware.configuration.disable_factory_reset = false;
|
||||
const p = fakeProps();
|
||||
p.controlPanelState.power_and_reset = true;
|
||||
const wrapper = mount(<PowerAndReset {...p} />);
|
||||
const wrapper =mount<>(<PowerAndReset {...p} />);
|
||||
wrapper.find("button").at(3).simulate("click");
|
||||
expect(mockDevice.updateConfig)
|
||||
.toHaveBeenCalledWith({ disable_factory_reset: true });
|
||||
|
|
|
@ -14,7 +14,7 @@ describe("<HomingRow />", () => {
|
|||
jest.clearAllMocks();
|
||||
});
|
||||
it("calls device", () => {
|
||||
const result = mount(<CalibrationRow
|
||||
const result =mount<>(<CalibrationRow
|
||||
hardware={bot.hardware.mcu_params}
|
||||
botDisconnected={false} />);
|
||||
[0, 1, 2].map(i => result.find("LockableButton").at(i).simulate("click"));
|
||||
|
|
|
@ -21,13 +21,13 @@ describe("<EncodersAndEndStops />", () => {
|
|||
|
||||
it("doesn't show new inversion param", () => {
|
||||
mockFeatures.endstop_invert = false;
|
||||
const wrapper = mount(<EncodersAndEndStops {...fakeProps()} />);
|
||||
const wrapper =mount<>(<EncodersAndEndStops {...fakeProps()} />);
|
||||
expect(wrapper.text().toLowerCase()).not.toContain("invert endstops");
|
||||
});
|
||||
|
||||
it("shows new inversion param", () => {
|
||||
mockFeatures.endstop_invert = true;
|
||||
const wrapper = mount(<EncodersAndEndStops {...fakeProps()} />);
|
||||
const wrapper =mount<>(<EncodersAndEndStops {...fakeProps()} />);
|
||||
expect(wrapper.text().toLowerCase()).not.toContain("invert endstops");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ describe("<HomingAndCalibration />", () => {
|
|||
const dispatch = jest.fn();
|
||||
bot.controlPanelState.homing_and_calibration = true;
|
||||
bot.hardware.informational_settings.firmware_version = fw;
|
||||
const result = mount(<HomingAndCalibration
|
||||
const result =mount<>(<HomingAndCalibration
|
||||
dispatch={dispatch}
|
||||
bot={bot}
|
||||
firmwareConfig={fakeFirmwareConfig().body}
|
||||
|
|
|
@ -16,7 +16,7 @@ describe("<HomingRow />", () => {
|
|||
});
|
||||
|
||||
it("renders three buttons", () => {
|
||||
const wrapper = mount(<HomingRow
|
||||
const wrapper =mount<>(<HomingRow
|
||||
hardware={bot.hardware.mcu_params}
|
||||
botDisconnected={false} />);
|
||||
const txt = wrapper.text().toUpperCase();
|
||||
|
@ -26,7 +26,7 @@ describe("<HomingRow />", () => {
|
|||
});
|
||||
|
||||
it("calls device", () => {
|
||||
const result = mount(<HomingRow
|
||||
const result =mount<>(<HomingRow
|
||||
hardware={bot.hardware.mcu_params}
|
||||
botDisconnected={false} />);
|
||||
[0, 1, 2].map(i =>
|
||||
|
|
|
@ -76,7 +76,7 @@ describe("<Motors/>", () => {
|
|||
const p = fakeProps();
|
||||
p.controlPanelState.motors = true;
|
||||
bot.hardware.mcu_params[parameter] = 1;
|
||||
const wrapper = mount(<Motors {...p} />);
|
||||
const wrapper =mount<>(<Motors {...p} />);
|
||||
wrapper.find("button").at(position).simulate("click");
|
||||
expect(mockDevice.updateMcu)
|
||||
.toHaveBeenCalledWith({ [parameter]: 0 });
|
||||
|
|
|
@ -13,7 +13,7 @@ describe("<HomingRow />", () => {
|
|||
jest.clearAllMocks();
|
||||
});
|
||||
it("calls device", () => {
|
||||
const result = mount(<ZeroRow botDisconnected={false} />);
|
||||
const result =mount<>(<ZeroRow botDisconnected={false} />);
|
||||
[0, 1, 2].map(i => result.find("ZeroButton").at(i).simulate("click"));
|
||||
["x", "y", "z"].map(x =>
|
||||
expect(mockDevice.setZero).toHaveBeenCalledWith(x));
|
||||
|
|
|
@ -5,7 +5,7 @@ import { mount } from "enzyme";
|
|||
|
||||
describe("<Diagnosis/>", () => {
|
||||
it("renders help text", () => {
|
||||
const el = mount(<Diagnosis
|
||||
const el =mount<>(<Diagnosis
|
||||
userAPI={true}
|
||||
userMQTT={true}
|
||||
botMQTT={true}
|
||||
|
@ -16,7 +16,7 @@ describe("<Diagnosis/>", () => {
|
|||
});
|
||||
|
||||
it("renders diagnosis error color", () => {
|
||||
const el = mount(<Diagnosis
|
||||
const el =mount<>(<Diagnosis
|
||||
userAPI={true}
|
||||
userMQTT={true}
|
||||
botMQTT={true}
|
||||
|
|
|
@ -58,14 +58,14 @@ describe("<ConnectivityDiagram/>", () => {
|
|||
}
|
||||
|
||||
it("renders diagram", () => {
|
||||
const wrapper = mount(<ConnectivityDiagram {...fakeProps() } />);
|
||||
const wrapper =mount<>(<ConnectivityDiagram {...fakeProps() } />);
|
||||
expect(wrapper.text())
|
||||
.toContain("BrowserWeb AppMessage BrokerFarmBotRaspberry PiF");
|
||||
});
|
||||
|
||||
it("hover", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<ConnectivityDiagram {...p } />);
|
||||
const wrapper =mount<>(<ConnectivityDiagram {...p } />);
|
||||
wrapper.find(".connector-hover-area").first().simulate("mouseEnter");
|
||||
expect(p.hover).toHaveBeenCalledWith("EF");
|
||||
});
|
||||
|
@ -130,7 +130,7 @@ describe("<Connector/>", () => {
|
|||
}
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<Connector {...fakeProps() } />);
|
||||
const wrapper =mount<>(<Connector {...fakeProps() } />);
|
||||
const lines = wrapper.find("line");
|
||||
expect(lines.length).toEqual(3);
|
||||
expect(lines.at(0).props())
|
||||
|
@ -154,7 +154,7 @@ describe("<Connector/>", () => {
|
|||
it("renders connected color", () => {
|
||||
const p = fakeProps();
|
||||
p.connectionData.connectionStatus = true;
|
||||
const wrapper = mount(<Connector {...p } />);
|
||||
const wrapper =mount<>(<Connector {...p } />);
|
||||
expect(wrapper.find("line").at(1).props().stroke).toEqual(Color.green);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -39,6 +39,6 @@ describe("<ConnectivityPanel/>", () => {
|
|||
const testcase = test();
|
||||
const el = mount(testcase.component);
|
||||
el.find(".saucer").last().simulate("mouseEnter");
|
||||
expect(el.state().hoveredConnection).toEqual("AB");
|
||||
expect(el.instance().state.hoveredConnection).toEqual("AB");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -32,33 +32,33 @@ describe("<DropArea />", () => {
|
|||
it("handles drag enter", () => {
|
||||
const preventDefault = jest.fn();
|
||||
const wrapper = shallow(<DropArea {...props()} />);
|
||||
expect(wrapper.state().isHovered).toEqual(false);
|
||||
expect(wrapper.instance().state.isHovered).toEqual(false);
|
||||
wrapper.simulate("dragEnter", { preventDefault });
|
||||
expect(preventDefault).toHaveBeenCalled();
|
||||
expect(wrapper.state().isHovered).toEqual(true);
|
||||
expect(wrapper.instance().state.isHovered).toEqual(true);
|
||||
});
|
||||
|
||||
it("handles drag leave", () => {
|
||||
const wrapper = shallow(<DropArea {...props()} />);
|
||||
wrapper.setState({ isHovered: true });
|
||||
wrapper.simulate("dragLeave");
|
||||
expect(wrapper.state().isHovered).toEqual(false);
|
||||
expect(wrapper.instance().state.isHovered).toEqual(false);
|
||||
});
|
||||
|
||||
it("handles drag over", () => {
|
||||
const preventDefault = jest.fn();
|
||||
const wrapper = shallow(<DropArea {...props()} />);
|
||||
expect(wrapper.state().isHovered).toEqual(false);
|
||||
expect(wrapper.instance().state.isHovered).toEqual(false);
|
||||
wrapper.simulate("dragOver", { preventDefault });
|
||||
expect(preventDefault).toHaveBeenCalled();
|
||||
expect(wrapper.state().isHovered).toEqual(false);
|
||||
expect(wrapper.instance().state.isHovered).toEqual(false);
|
||||
});
|
||||
|
||||
it("handles drop", () => {
|
||||
const preventDefault = jest.fn();
|
||||
const p = props();
|
||||
const wrapper = shallow(<DropArea {...p} />);
|
||||
expect(wrapper.state().isHovered).toEqual(false);
|
||||
expect(wrapper.instance().state.isHovered).toEqual(false);
|
||||
wrapper.simulate("drop", {
|
||||
preventDefault, dataTransfer: {
|
||||
getData: () => "key"
|
||||
|
@ -66,6 +66,6 @@ describe("<DropArea />", () => {
|
|||
});
|
||||
expect(p.callback).toHaveBeenCalledWith("key");
|
||||
expect(preventDefault).toHaveBeenCalled();
|
||||
expect(wrapper.state().isHovered).toEqual(true);
|
||||
expect(wrapper.instance().state.isHovered).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ import { FallbackWidget } from "../fallback_widget";
|
|||
describe("<FallbackWidget/>", function () {
|
||||
|
||||
it("renders widget fallback", function () {
|
||||
const wrapper = mount(<FallbackWidget title="FakeWidget" />);
|
||||
const wrapper =mount<>(<FallbackWidget title="FakeWidget" />);
|
||||
const widget = wrapper.find(".widget-wrapper");
|
||||
const header = widget.find(".widget-header");
|
||||
expect(header.text()).toContain("FakeWidget");
|
||||
|
|
|
@ -64,7 +64,7 @@ describe("<FarmDesigner/>", () => {
|
|||
|
||||
it("loads default map settings", () => {
|
||||
localStorage["showPoints"] = "false";
|
||||
const wrapper = mount(<FarmDesigner {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmDesigner {...fakeProps()} />);
|
||||
const legendProps = wrapper.find("GardenMapLegend").props() as GardenMapLegendProps;
|
||||
expect(legendProps.legendMenuOpen).toBeFalsy();
|
||||
expect(legendProps.showPlants).toBeTruthy();
|
||||
|
@ -87,7 +87,7 @@ describe("<FarmDesigner/>", () => {
|
|||
image1.body.created_at = "2001-01-03T00:00:00.000Z";
|
||||
image2.body.created_at = "2001-01-01T00:00:00.000Z";
|
||||
p.latestImages = [image1, image2];
|
||||
const wrapper = mount(<FarmDesigner {...p} />);
|
||||
const wrapper =mount<>(<FarmDesigner {...p} />);
|
||||
const legendProps = wrapper.find("GardenMapLegend").props() as GardenMapLegendProps;
|
||||
expect(legendProps.imageAgeInfo)
|
||||
.toEqual({ newestDate: "2001-01-03T00:00:00.000Z", toOldest: 2 });
|
||||
|
@ -95,7 +95,7 @@ describe("<FarmDesigner/>", () => {
|
|||
|
||||
it("renders nav titles", () => {
|
||||
mockPath = "/app/designer/plants";
|
||||
const wrapper = mount(<FarmDesigner {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmDesigner {...fakeProps()} />);
|
||||
["Map", "Plants", "Farm Events"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
expect(wrapper.find(".panel-header").first().hasClass("hidden")).toBeTruthy();
|
||||
|
@ -105,7 +105,7 @@ describe("<FarmDesigner/>", () => {
|
|||
|
||||
it("hides panel", () => {
|
||||
mockPath = "/app/designer";
|
||||
const wrapper = mount(<FarmDesigner {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmDesigner {...fakeProps()} />);
|
||||
["Map", "Plants", "Farm Events"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
expect(wrapper.find(".panel-header").first().hasClass("hidden")).toBeFalsy();
|
||||
|
|
|
@ -39,7 +39,7 @@ describe("<AddFarmEvent />", () => {
|
|||
}
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<AddFarmEvent {...fakeProps()} />);
|
||||
const wrapper =mount<>(<AddFarmEvent {...fakeProps()} />);
|
||||
wrapper.setState({ uuid: "FarmEvent" });
|
||||
["Add Farm Event", "Sequence or Regimen", "fake", "Save"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
|
@ -49,7 +49,7 @@ describe("<AddFarmEvent />", () => {
|
|||
});
|
||||
|
||||
it("redirects", () => {
|
||||
const wrapper = mount(<AddFarmEvent {...fakeProps()} />);
|
||||
const wrapper =mount<>(<AddFarmEvent {...fakeProps()} />);
|
||||
expect(wrapper.text()).toContain("Loading");
|
||||
});
|
||||
|
||||
|
@ -63,7 +63,7 @@ describe("<AddFarmEvent />", () => {
|
|||
|
||||
it("cleans up when unmounting", () => {
|
||||
const props = fakeProps();
|
||||
const wrapper = mount(<AddFarmEvent {...props} />);
|
||||
const wrapper =mount<>(<AddFarmEvent {...props} />);
|
||||
wrapper.update();
|
||||
const uuid: string = wrapper.state("uuid");
|
||||
props.farmEvents[0].uuid = uuid;
|
||||
|
|
|
@ -37,7 +37,7 @@ describe("<EditFarmEvent />", () => {
|
|||
}
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<EditFarmEvent {...fakeProps()} />);
|
||||
const wrapper =mount<>(<EditFarmEvent {...fakeProps()} />);
|
||||
["Edit Farm Event", "Sequence or Regimen", "fake", "Save"]
|
||||
.map(string => expect(wrapper.text()).toContain(string));
|
||||
const deleteBtn = wrapper.find("button").last();
|
||||
|
@ -48,7 +48,7 @@ describe("<EditFarmEvent />", () => {
|
|||
it("redirects", () => {
|
||||
const p = fakeProps();
|
||||
p.getFarmEvent = jest.fn();
|
||||
const wrapper = mount(<EditFarmEvent {...p} />);
|
||||
const wrapper =mount<>(<EditFarmEvent {...p} />);
|
||||
expect(wrapper.text()).toContain("Loading");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,7 +42,7 @@ describe("<FarmEventForm/>", () => {
|
|||
});
|
||||
|
||||
function instance(p: EditFEProps) {
|
||||
return mount(<EditFEForm {...p} />).instance() as EditFEForm;
|
||||
returnmount<>(<EditFEForm {...p} />).instance() as EditFEForm;
|
||||
}
|
||||
const context = { form: new EditFEForm(props()) };
|
||||
|
||||
|
@ -196,7 +196,7 @@ describe("<FarmEventForm/>", () => {
|
|||
const seq = fakeSequence();
|
||||
const fe = fakeFarmEvent("Sequence", seq.body.id || 0);
|
||||
fe.specialStatus = SpecialStatus.DIRTY;
|
||||
const el = mount(<EditFEForm
|
||||
const el =mount<>(<EditFEForm
|
||||
farmEvent={fe}
|
||||
title=""
|
||||
deviceTimezone="America/Chicago"
|
||||
|
|
|
@ -17,7 +17,7 @@ describe("<DrawnPoint/>", () => {
|
|||
}
|
||||
|
||||
it("renders point", () => {
|
||||
const wrapper = mount(<DrawnPoint {...fakeProps()} />);
|
||||
const wrapper =mount<>(<DrawnPoint {...fakeProps()} />);
|
||||
expect(wrapper.find("g").props().stroke).toEqual("red");
|
||||
expect(wrapper.find("circle").first().props()).toEqual({
|
||||
id: "point-radius", strokeDasharray: "4 5",
|
||||
|
|
|
@ -172,7 +172,7 @@ describe("<GardenPlant/>", () => {
|
|||
wrapper.setState({ isDragging: true });
|
||||
wrapper.find("#drop-area-svg").simulate("mouseUp");
|
||||
expect(p.dispatch).toHaveBeenCalled();
|
||||
expect(wrapper.state().isDragging).toBeFalsy();
|
||||
expect(wrapper.instance().state.isDragging).toBeFalsy();
|
||||
});
|
||||
|
||||
it("drags: editing", () => {
|
||||
|
|
|
@ -97,7 +97,7 @@ describe("<ImageFilterMenu />", () => {
|
|||
p.imageAgeInfo.newestDate = "2001-01-03T05:00:00.000Z";
|
||||
const wrapper = shallow(<ImageFilterMenu {...p} />);
|
||||
wrapper.find("Slider").simulate("change", 1);
|
||||
expect(wrapper.state().slider).toEqual(1);
|
||||
expect(wrapper.instance().state.slider).toEqual(1);
|
||||
expect(setWebAppConfigValue)
|
||||
.toHaveBeenCalledWith("photo_filter_begin", "2001-01-02T00:00:00.000Z");
|
||||
expect(setWebAppConfigValue)
|
||||
|
@ -107,7 +107,7 @@ describe("<ImageFilterMenu />", () => {
|
|||
it("displays slider labels", () => {
|
||||
const p = fakeProps();
|
||||
p.imageAgeInfo.newestDate = "2001-01-03T00:00:00.000Z";
|
||||
const wrapper = mount(<ImageFilterMenu {...p} />);
|
||||
const wrapper =mount<>(<ImageFilterMenu {...p} />);
|
||||
["Jan-1", "Jan-2", "Jan-3"].map(date =>
|
||||
expect(wrapper.text()).toContain(date));
|
||||
});
|
||||
|
|
|
@ -35,7 +35,7 @@ describe("<MapImage />", () => {
|
|||
};
|
||||
|
||||
it("doesn't render image", () => {
|
||||
const wrapper = mount(<MapImage {...fakeProps()} />);
|
||||
const wrapper =mount<>(<MapImage {...fakeProps()} />);
|
||||
expect(wrapper.html()).toEqual("<image></image>");
|
||||
});
|
||||
|
||||
|
@ -61,7 +61,7 @@ describe("<MapImage />", () => {
|
|||
expectedData: ExpectedData,
|
||||
extra?: ExtraTranslationData) => {
|
||||
it(`renders image: INPUT_SET_${num}`, () => {
|
||||
const wrapper = mount(<MapImage {...inputData[num]} />);
|
||||
const wrapper =mount<>(<MapImage {...inputData[num]} />);
|
||||
expect(wrapper.find("image").props()).toEqual({
|
||||
xlinkHref: "image_url",
|
||||
x: 0,
|
||||
|
@ -155,21 +155,21 @@ describe("<MapImage />", () => {
|
|||
it("doesn't render placeholder image", () => {
|
||||
const p = INPUT_SET_1;
|
||||
p.image && (p.image.body.attachment_url = "/placehold.");
|
||||
const wrapper = mount(<MapImage {...p} />);
|
||||
const wrapper =mount<>(<MapImage {...p} />);
|
||||
expect(wrapper.html()).toEqual("<image></image>");
|
||||
});
|
||||
|
||||
it("doesn't render image taken at different height than calibration", () => {
|
||||
const p = INPUT_SET_1;
|
||||
p.image && (p.image.body.meta.z = 100);
|
||||
const wrapper = mount(<MapImage {...p} />);
|
||||
const wrapper =mount<>(<MapImage {...p} />);
|
||||
expect(wrapper.html()).toEqual("<image></image>");
|
||||
});
|
||||
|
||||
it("doesn't render images that are not adjusted for camera rotation", () => {
|
||||
const p = INPUT_SET_1;
|
||||
p.image && (p.image.body.meta.name = "na");
|
||||
const wrapper = mount(<MapImage {...p} />);
|
||||
const wrapper =mount<>(<MapImage {...p} />);
|
||||
expect(wrapper.html()).toEqual("<image></image>");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -29,7 +29,7 @@ describe("<ToolbaySlot />", () => {
|
|||
p.pulloutDirection = direction;
|
||||
p.quadrant = quadrant;
|
||||
p.xySwap = xySwap;
|
||||
const wrapper = mount(<ToolbaySlot {...p} />);
|
||||
const wrapper =mount<>(<ToolbaySlot {...p} />);
|
||||
expect(wrapper.find("use").props().transform).toEqual(expected);
|
||||
});
|
||||
};
|
||||
|
@ -76,7 +76,7 @@ describe("<Tool/>", () => {
|
|||
};
|
||||
|
||||
it("renders standard tool styling", () => {
|
||||
const wrapper = mount(<Tool {...fakeProps()} />);
|
||||
const wrapper =mount<>(<Tool {...fakeProps()} />);
|
||||
const props = wrapper.find("circle").last().props();
|
||||
expect(props.r).toEqual(35);
|
||||
expect(props.cx).toEqual(10);
|
||||
|
@ -87,7 +87,7 @@ describe("<Tool/>", () => {
|
|||
it("tool hover", () => {
|
||||
const p = fakeProps();
|
||||
p.toolProps.hovered = true;
|
||||
const wrapper = mount(<Tool {...p} />);
|
||||
const wrapper =mount<>(<Tool {...p} />);
|
||||
const props = wrapper.find("circle").last().props();
|
||||
expect(props.fill).toEqual(Color.darkGray);
|
||||
});
|
||||
|
@ -95,7 +95,7 @@ describe("<Tool/>", () => {
|
|||
it("renders special tool styling: bin", () => {
|
||||
const p = fakeProps();
|
||||
p.tool = "seedBin";
|
||||
const wrapper = mount(<Tool {...p} />);
|
||||
const wrapper =mount<>(<Tool {...p} />);
|
||||
const elements = wrapper.find("#seed-bin").find("circle");
|
||||
expect(elements.length).toEqual(2);
|
||||
expect(elements.last().props().fill).toEqual("url(#SeedBinGradient)");
|
||||
|
@ -105,7 +105,7 @@ describe("<Tool/>", () => {
|
|||
const p = fakeProps();
|
||||
p.tool = "seedBin";
|
||||
p.toolProps.hovered = true;
|
||||
const wrapper = mount(<Tool {...p} />);
|
||||
const wrapper =mount<>(<Tool {...p} />);
|
||||
p.toolProps.hovered = true;
|
||||
expect(wrapper.find("#seed-bin").find("circle").length).toEqual(3);
|
||||
});
|
||||
|
@ -113,7 +113,7 @@ describe("<Tool/>", () => {
|
|||
it("renders special tool styling: tray", () => {
|
||||
const p = fakeProps();
|
||||
p.tool = "seedTray";
|
||||
const wrapper = mount(<Tool {...p} />);
|
||||
const wrapper =mount<>(<Tool {...p} />);
|
||||
const elements = wrapper.find("#seed-tray");
|
||||
expect(elements.find("circle").length).toEqual(2);
|
||||
expect(elements.find("rect").length).toEqual(1);
|
||||
|
@ -124,7 +124,7 @@ describe("<Tool/>", () => {
|
|||
const p = fakeProps();
|
||||
p.tool = "seedTray";
|
||||
p.toolProps.hovered = true;
|
||||
const wrapper = mount(<Tool {...p} />);
|
||||
const wrapper =mount<>(<Tool {...p} />);
|
||||
p.toolProps.hovered = true;
|
||||
expect(wrapper.find("#seed-tray").find("circle").length).toEqual(3);
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ describe("<ToolSlotPoint/>", () => {
|
|||
const p = fakeProps();
|
||||
if (!tool) { p.slot.tool = undefined; }
|
||||
p.slot.toolSlot.body.pullout_direction = slot;
|
||||
const wrapper = mount(<ToolSlotPoint {...p} />);
|
||||
const wrapper =mount<>(<ToolSlotPoint {...p} />);
|
||||
expect(wrapper.find("circle").length).toEqual(tool);
|
||||
expect(wrapper.find("use").length).toEqual(slot);
|
||||
});
|
||||
|
@ -31,7 +31,7 @@ describe("<ToolSlotPoint/>", () => {
|
|||
it("displays tool name", () => {
|
||||
const p = fakeProps();
|
||||
p.slot.toolSlot.body.pullout_direction = 2;
|
||||
const wrapper = mount(<ToolSlotPoint {...p} />);
|
||||
const wrapper =mount<>(<ToolSlotPoint {...p} />);
|
||||
wrapper.setState({ hovered: true });
|
||||
expect(wrapper.find("text").props().visibility).toEqual("visible");
|
||||
expect(wrapper.find("text").text()).toEqual("Foo");
|
||||
|
@ -41,28 +41,28 @@ describe("<ToolSlotPoint/>", () => {
|
|||
it("displays 'no tool'", () => {
|
||||
const p = fakeProps();
|
||||
p.slot.tool = undefined;
|
||||
const wrapper = mount(<ToolSlotPoint {...p} />);
|
||||
const wrapper =mount<>(<ToolSlotPoint {...p} />);
|
||||
wrapper.setState({ hovered: true });
|
||||
expect(wrapper.find("text").text()).toEqual("no tool");
|
||||
expect(wrapper.find("text").props().dx).toEqual(40);
|
||||
});
|
||||
|
||||
it("doesn't display tool name", () => {
|
||||
const wrapper = mount(<ToolSlotPoint {...fakeProps()} />);
|
||||
const wrapper =mount<>(<ToolSlotPoint {...fakeProps()} />);
|
||||
expect(wrapper.find("text").props().visibility).toEqual("hidden");
|
||||
});
|
||||
|
||||
it("renders bin", () => {
|
||||
const p = fakeProps();
|
||||
if (p.slot.tool) { p.slot.tool.body.name = "seed bin"; }
|
||||
const wrapper = mount(<ToolSlotPoint {...p} />);
|
||||
const wrapper =mount<>(<ToolSlotPoint {...p} />);
|
||||
expect(wrapper.find("#SeedBinGradient").length).toEqual(1);
|
||||
});
|
||||
|
||||
it("renders tray", () => {
|
||||
const p = fakeProps();
|
||||
if (p.slot.tool) { p.slot.tool.body.name = "seed tray"; }
|
||||
const wrapper = mount(<ToolSlotPoint {...p} />);
|
||||
const wrapper =mount<>(<ToolSlotPoint {...p} />);
|
||||
expect(wrapper.find("#SeedTrayPattern").length).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,8 +34,8 @@ describe("<Bugs />", () => {
|
|||
it("kills bugs", () => {
|
||||
setEggStatus(EggKeys.BUGS_ARE_STILL_ALIVE, "");
|
||||
expectAlive("");
|
||||
const wrapper = mount(<Bugs {...fakeProps()} />);
|
||||
wrapper.state().bugs[0].r = 101;
|
||||
const wrapper =mount<>(<Bugs {...fakeProps()} />);
|
||||
wrapper.instance().state.bugs[0].r = 101;
|
||||
range(10).map(b =>
|
||||
wrapper.find("image").at(b).simulate("click"));
|
||||
expectAlive("");
|
||||
|
@ -48,7 +48,7 @@ describe("<Bugs />", () => {
|
|||
className: expect.stringContaining("dead"),
|
||||
filter: expect.stringContaining("grayscale")
|
||||
}));
|
||||
expect(wrapper.state().bugs[0]).toEqual(expect.objectContaining({
|
||||
expect(wrapper.instance().state.bugs[0]).toEqual(expect.objectContaining({
|
||||
alive: false, hp: 50
|
||||
}));
|
||||
});
|
||||
|
|
|
@ -87,17 +87,17 @@ describe("<BotFigure/>", () => {
|
|||
const p = fakeProps();
|
||||
p.position.x = 100;
|
||||
const wrapper = shallow(<BotFigure {...p} />);
|
||||
expect(wrapper.state().hovered).toBeFalsy();
|
||||
expect(wrapper.instance().state.hovered).toBeFalsy();
|
||||
const utm = wrapper.find("#UTM");
|
||||
utm.simulate("mouseOver");
|
||||
expect(wrapper.state().hovered).toBeTruthy();
|
||||
expect(wrapper.instance().state.hovered).toBeTruthy();
|
||||
expect(wrapper.find("text").props()).toEqual(expect.objectContaining({
|
||||
x: 100, y: 0, dx: 40, dy: 0,
|
||||
textAnchor: "start", visibility: "visible",
|
||||
}));
|
||||
expect(wrapper.text()).toEqual("(100, 0, 0)");
|
||||
utm.simulate("mouseLeave");
|
||||
expect(wrapper.state().hovered).toBeFalsy();
|
||||
expect(wrapper.instance().state.hovered).toBeFalsy();
|
||||
expect(wrapper.find("text").props()).toEqual(
|
||||
expect.objectContaining({ visibility: "hidden" }));
|
||||
});
|
||||
|
@ -109,7 +109,7 @@ describe("<BotFigure/>", () => {
|
|||
const wrapper = shallow(<BotFigure {...p} />);
|
||||
const utm = wrapper.find("#UTM");
|
||||
utm.simulate("mouseOver");
|
||||
expect(wrapper.state().hovered).toBeTruthy();
|
||||
expect(wrapper.instance().state.hovered).toBeTruthy();
|
||||
expect(wrapper.find("text").props()).toEqual(expect.objectContaining({
|
||||
x: 0, y: 100, dx: 0, dy: 55,
|
||||
textAnchor: "middle", visibility: "visible",
|
||||
|
|
|
@ -30,7 +30,7 @@ describe("<AddPlant />", () => {
|
|||
}]
|
||||
};
|
||||
mockPath = "/app/designer/plants/crop_search/mint/add";
|
||||
const wrapper = mount(<AddPlant {...props} />);
|
||||
const wrapper =mount<>(<AddPlant {...props} />);
|
||||
expect(wrapper.text()).toContain("Mint");
|
||||
expect(wrapper.text()).toContain("Done");
|
||||
expect(wrapper.find("img").props().src)
|
||||
|
|
|
@ -30,13 +30,13 @@ describe("<CreatePoints />", () => {
|
|||
};
|
||||
};
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<CreatePoints {...fakeProps()} />);
|
||||
const wrapper =mount<>(<CreatePoints {...fakeProps()} />);
|
||||
["create point", "cancel", "delete", "x", "y", "radius", "color"]
|
||||
.map(string => expect(wrapper.text().toLowerCase()).toContain(string));
|
||||
});
|
||||
|
||||
it("creates point", () => {
|
||||
const wrapper = mount(<CreatePoints {...fakeProps()} />);
|
||||
const wrapper =mount<>(<CreatePoints {...fakeProps()} />);
|
||||
wrapper.setState({ cx: 10, cy: 20, r: 30, color: "red" });
|
||||
clickButton(wrapper, 0, "create point");
|
||||
expect(initSave).toHaveBeenCalledWith({
|
||||
|
@ -54,7 +54,7 @@ describe("<CreatePoints />", () => {
|
|||
|
||||
it("deletes all points", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<CreatePoints {...p} />);
|
||||
const wrapper =mount<>(<CreatePoints {...p} />);
|
||||
const button = wrapper.find("button").last();
|
||||
expect(button.text()).toEqual("Delete all created points");
|
||||
window.confirm = jest.fn();
|
||||
|
|
|
@ -45,7 +45,7 @@ describe("<CropInfo />", () => {
|
|||
|
||||
it("renders", () => {
|
||||
mockPath = "/app/designer/plants/crop_search/mint";
|
||||
const wrapper = mount(<CropInfo {...fakeProps()} />);
|
||||
const wrapper =mount<>(<CropInfo {...fakeProps()} />);
|
||||
expect(wrapper.text()).toContain("Mint");
|
||||
expect(wrapper.text()).toContain("Drag and drop into map");
|
||||
expect(wrapper.text()).toContain("Row Spacing1000mm");
|
||||
|
|
|
@ -31,7 +31,7 @@ describe("<EditPlantInfo />", () => {
|
|||
};
|
||||
|
||||
it("renders", async () => {
|
||||
const wrapper = mount(<EditPlantInfo {...fakeProps()} />);
|
||||
const wrapper =mount<>(<EditPlantInfo {...fakeProps()} />);
|
||||
expect(wrapper.text()).toContain("Strawberry Plant 1");
|
||||
expect(wrapper.text().replace(/\s+/g, " "))
|
||||
.toContain("Plant Type: Strawberry");
|
||||
|
@ -40,7 +40,7 @@ describe("<EditPlantInfo />", () => {
|
|||
it("deletes plant", async () => {
|
||||
const p = fakeProps();
|
||||
p.dispatch = jest.fn(() => { return Promise.resolve(); });
|
||||
const wrapper = mount(<EditPlantInfo {...p} />);
|
||||
const wrapper =mount<>(<EditPlantInfo {...p} />);
|
||||
const deleteButton = wrapper.find("button").at(2);
|
||||
expect(deleteButton.text()).toEqual("Delete");
|
||||
expect(deleteButton.props().hidden).toBeFalsy();
|
||||
|
|
|
@ -34,7 +34,7 @@ describe("<MoveTo />", () => {
|
|||
}
|
||||
|
||||
it("moves to location: bot's current z value", () => {
|
||||
const wrapper = mount(<MoveTo {...fakeProps()} />);
|
||||
const wrapper =mount<>(<MoveTo {...fakeProps()} />);
|
||||
wrapper.find("button").simulate("click");
|
||||
expect(mockDevice.moveAbsolute).toHaveBeenCalledWith({ x: 1, y: 2, z: 30 });
|
||||
});
|
||||
|
@ -49,7 +49,7 @@ describe("<MoveToForm />", () => {
|
|||
}
|
||||
|
||||
it("moves to location: custom z value", () => {
|
||||
const wrapper = mount(<MoveToForm {...fakeProps()} />);
|
||||
const wrapper =mount<>(<MoveToForm {...fakeProps()} />);
|
||||
wrapper.setState({ z: 50 });
|
||||
wrapper.find("button").simulate("click");
|
||||
expect(mockDevice.moveAbsolute).toHaveBeenCalledWith({ x: 1, y: 2, z: 50 });
|
||||
|
|
|
@ -22,7 +22,7 @@ describe("<OpenFarmResults/>", () => {
|
|||
},
|
||||
]
|
||||
};
|
||||
const el = mount(<OpenFarmResults {...props} />);
|
||||
const el =mount<>(<OpenFarmResults {...props} />);
|
||||
const text = el.text();
|
||||
expect(text).toContain(props.cropSearchResults[0].crop.name);
|
||||
expect(text).toContain(props.cropSearchResults[1].crop.name);
|
||||
|
|
|
@ -36,14 +36,14 @@ describe("<SelectPlants />", () => {
|
|||
}
|
||||
|
||||
it("displays selected plant", () => {
|
||||
const wrapper = mount(<SelectPlants {...fakeProps()} />);
|
||||
const wrapper =mount<>(<SelectPlants {...fakeProps()} />);
|
||||
expect(wrapper.text()).toContain("Strawberry");
|
||||
});
|
||||
|
||||
it("displays multiple selected plants", () => {
|
||||
const p = fakeProps();
|
||||
p.selected = ["plant.1", "plant.2"];
|
||||
const wrapper = mount(<SelectPlants {...p} />);
|
||||
const wrapper =mount<>(<SelectPlants {...p} />);
|
||||
["Strawberry", "Blueberry", "Delete"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
});
|
||||
|
@ -51,21 +51,21 @@ describe("<SelectPlants />", () => {
|
|||
it("displays no selected plants: selection empty", () => {
|
||||
const p = fakeProps();
|
||||
p.selected = [];
|
||||
const wrapper = mount(<SelectPlants {...p} />);
|
||||
const wrapper =mount<>(<SelectPlants {...p} />);
|
||||
expect(wrapper.text()).not.toContain("Strawberry Plant");
|
||||
});
|
||||
|
||||
it("displays no selected plants: selection invalid", () => {
|
||||
const p = fakeProps();
|
||||
p.selected = ["not a uuid"];
|
||||
const wrapper = mount(<SelectPlants {...p} />);
|
||||
const wrapper =mount<>(<SelectPlants {...p} />);
|
||||
expect(wrapper.text()).not.toContain("Strawberry Plant");
|
||||
});
|
||||
|
||||
it("selects all", () => {
|
||||
const p = fakeProps();
|
||||
p.dispatch = jest.fn();
|
||||
const wrapper = mount(<SelectPlants {...p} />);
|
||||
const wrapper =mount<>(<SelectPlants {...p} />);
|
||||
clickButton(wrapper, 1, "select all");
|
||||
expect(p.dispatch).toHaveBeenCalledWith(
|
||||
{ payload: ["plant.1", "plant.2"], type: Actions.SELECT_PLANT });
|
||||
|
@ -74,7 +74,7 @@ describe("<SelectPlants />", () => {
|
|||
it("selects none", () => {
|
||||
const p = fakeProps();
|
||||
p.dispatch = jest.fn();
|
||||
const wrapper = mount(<SelectPlants {...p} />);
|
||||
const wrapper =mount<>(<SelectPlants {...p} />);
|
||||
clickButton(wrapper, 2, "select none");
|
||||
expect(p.dispatch).toHaveBeenCalledWith(
|
||||
{ payload: undefined, type: Actions.SELECT_PLANT });
|
||||
|
@ -83,7 +83,7 @@ describe("<SelectPlants />", () => {
|
|||
it("confirms deletion of selected plants", () => {
|
||||
const p = fakeProps();
|
||||
p.selected = ["plant.1", "plant.2"];
|
||||
const wrapper = mount(<SelectPlants {...p} />);
|
||||
const wrapper =mount<>(<SelectPlants {...p} />);
|
||||
expect(wrapper.text()).toContain("Delete");
|
||||
window.confirm = jest.fn();
|
||||
wrapper.find("button").first().simulate("click");
|
||||
|
|
|
@ -35,7 +35,7 @@ describe("<FarmwareConfigMenu />", () => {
|
|||
}
|
||||
|
||||
it("calls install 1st party farmwares", () => {
|
||||
const wrapper = mount(<FarmwareConfigMenu {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmwareConfigMenu {...fakeProps()} />);
|
||||
const button = wrapper.find("button").first();
|
||||
expect(button.hasClass("fa-download")).toBeTruthy();
|
||||
button.simulate("click");
|
||||
|
|
|
@ -60,7 +60,7 @@ describe("<ConfigFields />", () => {
|
|||
it("renders fields", () => {
|
||||
const p = fakeProps();
|
||||
p.farmware.config.push({ name: "config_2", label: "Config 2", value: "2" });
|
||||
const wrapper = mount(<ConfigFields {...fakeProps()} />);
|
||||
const wrapper =mount<>(<ConfigFields {...fakeProps()} />);
|
||||
expect(wrapper.text()).toEqual("Config 1");
|
||||
});
|
||||
|
||||
|
@ -84,7 +84,7 @@ describe("<FarmwareForm />", () => {
|
|||
};
|
||||
|
||||
it("renders form", () => {
|
||||
const wrapper = mount(<FarmwareForm {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmwareForm {...fakeProps()} />);
|
||||
["Run", "Config 1"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
expect(wrapper.find("label").last().text()).toContain("Config 1");
|
||||
|
@ -94,12 +94,12 @@ describe("<FarmwareForm />", () => {
|
|||
it("renders no fields", () => {
|
||||
const p = fakeProps();
|
||||
p.farmware.config = [];
|
||||
const wrapper = mount(<FarmwareForm {...p} />);
|
||||
const wrapper =mount<>(<FarmwareForm {...p} />);
|
||||
expect(wrapper.text()).toEqual("Run");
|
||||
});
|
||||
|
||||
it("runs farmware", () => {
|
||||
const wrapper = mount(<FarmwareForm {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmwareForm {...fakeProps()} />);
|
||||
clickButton(wrapper, 0, "run");
|
||||
expect(mockDevice.execScript).toHaveBeenCalledWith(
|
||||
"My Fake Farmware", [{
|
||||
|
|
|
@ -29,12 +29,12 @@ describe("<FarmwareInfo />", () => {
|
|||
it("renders no manifest info message", () => {
|
||||
const p = fakeProps();
|
||||
p.farmware = undefined;
|
||||
const wrapper = mount(<FarmwareInfo {...p} />);
|
||||
const wrapper =mount<>(<FarmwareInfo {...p} />);
|
||||
expect(wrapper.text()).toEqual("Not available when device is offline.");
|
||||
});
|
||||
|
||||
it("renders info", () => {
|
||||
const wrapper = mount(<FarmwareInfo {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmwareInfo {...fakeProps()} />);
|
||||
["Description", "Version", "Language", "Author", "Manage"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
expect(wrapper.text()).toContain("Does things.");
|
||||
|
@ -44,18 +44,18 @@ describe("<FarmwareInfo />", () => {
|
|||
const p = fakeProps();
|
||||
p.farmware = fakeFarmware();
|
||||
p.farmware.meta.author = "Farmbot.io";
|
||||
const wrapper = mount(<FarmwareInfo {...p} />);
|
||||
const wrapper =mount<>(<FarmwareInfo {...p} />);
|
||||
expect(wrapper.text()).toContain("FarmBot, Inc.");
|
||||
});
|
||||
|
||||
it("updates Farmware", () => {
|
||||
const wrapper = mount(<FarmwareInfo {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmwareInfo {...fakeProps()} />);
|
||||
clickButton(wrapper, 0, "Update");
|
||||
expect(mockDevice.updateFarmware).toHaveBeenCalledWith("My Fake Farmware");
|
||||
});
|
||||
|
||||
it("removes Farmware", () => {
|
||||
const wrapper = mount(<FarmwareInfo {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmwareInfo {...fakeProps()} />);
|
||||
clickButton(wrapper, 1, "Remove");
|
||||
expect(mockDevice.removeFarmware).toHaveBeenCalledWith("My Fake Farmware");
|
||||
});
|
||||
|
@ -65,7 +65,7 @@ describe("<FarmwareInfo />", () => {
|
|||
p.farmware = fakeFarmware();
|
||||
p.farmware.name = "Fake 1st-Party Farmware";
|
||||
p.firstPartyFarmwareNames = ["Fake 1st-Party Farmware"];
|
||||
const wrapper = mount(<FarmwareInfo {...p} />);
|
||||
const wrapper =mount<>(<FarmwareInfo {...p} />);
|
||||
clickButton(wrapper, 1, "Remove");
|
||||
expect(mockDevice.removeFarmware).not.toHaveBeenCalled();
|
||||
});
|
||||
|
@ -75,7 +75,7 @@ describe("<FarmwareInfo />", () => {
|
|||
p.farmware = fakeFarmware();
|
||||
p.farmware.name = "Fake 1st-Party Farmware";
|
||||
p.firstPartyFarmwareNames = ["Fake 1st-Party Farmware"];
|
||||
const wrapper = mount(<FarmwareInfo {...p} />);
|
||||
const wrapper =mount<>(<FarmwareInfo {...p} />);
|
||||
window.confirm = jest.fn(() => true);
|
||||
clickButton(wrapper, 1, "Remove");
|
||||
expect(window.confirm).toHaveBeenCalledWith(
|
||||
|
|
|
@ -25,7 +25,7 @@ describe("<FarmwareList />", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<FarmwareList {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmwareList {...fakeProps()} />);
|
||||
["Photos",
|
||||
"Camera Calibration",
|
||||
"Weed Detector",
|
||||
|
@ -39,8 +39,9 @@ describe("<FarmwareList />", () => {
|
|||
|
||||
it("doesn't install a new farmware without URL", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<FarmwareList {...p} />);
|
||||
expect(wrapper.state().packageUrl).toEqual("");
|
||||
const wrapper =
|
||||
mount<FarmwareList>(<FarmwareList {...p} />);
|
||||
expect(wrapper.instance().state.packageUrl).toEqual("");
|
||||
window.alert = jest.fn();
|
||||
clickButton(wrapper, 0, "Install");
|
||||
expect(window.alert).toHaveBeenCalledWith("Enter a URL");
|
||||
|
@ -50,17 +51,18 @@ describe("<FarmwareList />", () => {
|
|||
const FAKE_INSTALL_URL = "https://foo.bar/manifest.json";
|
||||
|
||||
it("changes install URL", () => {
|
||||
const wrapper = shallow(<FarmwareList {...fakeProps()} />);
|
||||
expect(wrapper.state().packageUrl).toEqual("");
|
||||
const wrapper =
|
||||
shallow<FarmwareList>(<FarmwareList {...fakeProps()} />);
|
||||
expect(wrapper.instance().state.packageUrl).toEqual("");
|
||||
wrapper.find("input").simulate("change", {
|
||||
currentTarget: { value: FAKE_INSTALL_URL }
|
||||
});
|
||||
expect(wrapper.state().packageUrl).toEqual(FAKE_INSTALL_URL);
|
||||
expect(wrapper.instance().state.packageUrl).toEqual(FAKE_INSTALL_URL);
|
||||
});
|
||||
|
||||
it("installs a new farmware", () => {
|
||||
const p = fakeProps();
|
||||
const wrapper = mount(<FarmwareList {...p} />);
|
||||
const wrapper =mount<>(<FarmwareList {...p} />);
|
||||
wrapper.setState({ packageUrl: FAKE_INSTALL_URL });
|
||||
window.alert = jest.fn();
|
||||
clickButton(wrapper, 0, "Install");
|
||||
|
@ -75,7 +77,7 @@ describe("<FarmwareList />", () => {
|
|||
p.farmwares["farmware_1"] = farmware;
|
||||
p.firstPartyFarmwareNames = ["Fake First-Party Farmware"];
|
||||
p.showFirstParty = false;
|
||||
const wrapper = mount(<FarmwareList {...p} />);
|
||||
const wrapper =mount<>(<FarmwareList {...p} />);
|
||||
expect(wrapper.text()).not.toContain("Fake First-Party Farmware");
|
||||
});
|
||||
|
||||
|
@ -86,7 +88,7 @@ describe("<FarmwareList />", () => {
|
|||
p.farmwares["farmware_1"] = farmware;
|
||||
p.firstPartyFarmwareNames = ["Fake First-Party Farmware"];
|
||||
p.showFirstParty = true;
|
||||
const wrapper = mount(<FarmwareList {...p} />);
|
||||
const wrapper =mount<>(<FarmwareList {...p} />);
|
||||
expect(wrapper.text()).toContain("Fake First-Party Farmware");
|
||||
});
|
||||
|
||||
|
|
|
@ -49,13 +49,13 @@ describe("<FarmwarePage />", () => {
|
|||
};
|
||||
|
||||
it("renders panels", () => {
|
||||
const wrapper = mount(<FarmwarePage {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmwarePage {...fakeProps()} />);
|
||||
["Farmware", "My Farmware"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
});
|
||||
|
||||
it("renders photos page by default", () => {
|
||||
const wrapper = mount(<FarmwarePage {...fakeProps()} />);
|
||||
const wrapper =mount<>(<FarmwarePage {...fakeProps()} />);
|
||||
expect(wrapper.text()).toContain("Take Photo");
|
||||
});
|
||||
|
||||
|
@ -72,7 +72,7 @@ describe("<FarmwarePage />", () => {
|
|||
it(`renders ${farmware} Farmware page`, () => {
|
||||
const p = fakeProps();
|
||||
p.currentFarmware = farmware;
|
||||
const wrapper = mount(<FarmwarePage {...p} />);
|
||||
const wrapper =mount<>(<FarmwarePage {...p} />);
|
||||
expectedText.map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
})
|
||||
|
@ -81,7 +81,7 @@ describe("<FarmwarePage />", () => {
|
|||
const p = fakeProps();
|
||||
p.farmwares["My Fake Farmware"] = fakeFarmware();
|
||||
p.currentFarmware = "My Fake Farmware";
|
||||
const wrapper = mount(<FarmwarePage {...p} />);
|
||||
const wrapper =mount<>(<FarmwarePage {...p} />);
|
||||
["My Fake Farmware", "Does things", "Run", "Config 1",
|
||||
"Information", "Description", "Version", "Update", "Remove"
|
||||
].map(string =>
|
||||
|
@ -94,7 +94,7 @@ describe("<FarmwarePage />", () => {
|
|||
farmware.config = [];
|
||||
p.farmwares["My Fake Farmware"] = farmware;
|
||||
p.currentFarmware = "My Fake Farmware";
|
||||
const wrapper = mount(<FarmwarePage {...p} />);
|
||||
const wrapper =mount<>(<FarmwarePage {...p} />);
|
||||
["My Fake Farmware", "Does things", "Run", "No inputs provided."
|
||||
].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
|
@ -106,7 +106,7 @@ describe("<FarmwarePage />", () => {
|
|||
farmware.config = [];
|
||||
p.farmwares["My Fake Farmware"] = farmware;
|
||||
p.currentFarmware = "My Fake Farmware";
|
||||
const wrapper = mount(<FarmwarePage {...p} />);
|
||||
const wrapper =mount<>(<FarmwarePage {...p} />);
|
||||
clickButton(wrapper, 1, "Run");
|
||||
expect(mockDevice.execScript).toHaveBeenCalledWith("My Fake Farmware");
|
||||
});
|
||||
|
|
|
@ -31,7 +31,7 @@ describe("<CameraCalibration/>", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<CameraCalibration {...props} />);
|
||||
const wrapper =mount<>(<CameraCalibration {...props} />);
|
||||
["Color Range",
|
||||
"HUE017947",
|
||||
"SATURATION025558",
|
||||
|
|
|
@ -118,7 +118,7 @@ describe("<ImageFlipper/>", () => {
|
|||
const images = prepareImages(fakeImages);
|
||||
const currentImage = images[1];
|
||||
const props = { images, currentImage, onFlip };
|
||||
const wrapper = mount(<ImageFlipper {...props} />);
|
||||
const wrapper =mount<>(<ImageFlipper {...props} />);
|
||||
const prevButton = wrapper.find("button").first();
|
||||
expect(prevButton.text().toLowerCase()).toBe("prev");
|
||||
expect(prevButton.props().disabled).toBeFalsy();
|
||||
|
|
|
@ -33,7 +33,7 @@ describe("<Photos/>", () => {
|
|||
const images = prepareImages(fakeImages);
|
||||
const currentImage = images[1];
|
||||
const props = { images, currentImage, dispatch, timeOffset: 0 };
|
||||
const wrapper = mount(<Photos {...props} />);
|
||||
const wrapper =mount<>(<Photos {...props} />);
|
||||
expect(wrapper.text()).toContain("Created At:June 1st, 2017");
|
||||
expect(wrapper.text()).toContain("X:632Y:347Z:164");
|
||||
});
|
||||
|
@ -45,7 +45,7 @@ describe("<Photos/>", () => {
|
|||
dispatch: jest.fn(),
|
||||
timeOffset: 0
|
||||
};
|
||||
const wrapper = mount(<Photos {...props} />);
|
||||
const wrapper =mount<>(<Photos {...props} />);
|
||||
expect(wrapper.text()).toContain("Image:No meta data.");
|
||||
});
|
||||
|
||||
|
@ -59,7 +59,7 @@ describe("<Photos/>", () => {
|
|||
dispatch,
|
||||
timeOffset: 0
|
||||
};
|
||||
const wrapper = mount(<Photos {...props} />);
|
||||
const wrapper =mount<>(<Photos {...props} />);
|
||||
clickButton(wrapper, 1, "delete photo");
|
||||
expect(destroy).toHaveBeenCalledWith("Position 1");
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ import { WeedDetectorConfig } from "../config"
|
|||
|
||||
describe("<WeedDetectorConfig />", () => {
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<WeedDetectorConfig
|
||||
const wrapper =mount<>(<WeedDetectorConfig
|
||||
values={{}} onChange={jest.fn()} />);
|
||||
["Invert Hue Range Selection",
|
||||
"Calibration Object Separation",
|
||||
|
|
|
@ -18,7 +18,7 @@ describe("Weed detector slider", () => {
|
|||
|
||||
it("releases the slider", () => {
|
||||
const onRelease = jest.fn();
|
||||
const el = shallow(<WeedDetectorSlider
|
||||
const el = shallow<WeedDetectorSlider>(<WeedDetectorSlider
|
||||
onRelease={onRelease}
|
||||
highest={99}
|
||||
lowest={1}
|
||||
|
@ -27,7 +27,7 @@ describe("Weed detector slider", () => {
|
|||
el.simulate("release", [5, 6]);
|
||||
jest.runAllTimers();
|
||||
expect(onRelease).toHaveBeenCalledWith([5, 6]);
|
||||
const { highValue, lowValue } = el.state();
|
||||
const { highValue, lowValue } = el.instance().state;
|
||||
expect(highValue).toBeUndefined();
|
||||
expect(lowValue).toBeUndefined();
|
||||
});
|
||||
|
|
|
@ -37,7 +37,7 @@ describe("<WeedDetector />", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<WeedDetector {...props} />);
|
||||
const wrapper =mount<>(<WeedDetector {...props} />);
|
||||
["Color Range",
|
||||
"HUE01793090",
|
||||
"SATURATION025550255",
|
||||
|
@ -55,9 +55,10 @@ describe("<WeedDetector />", () => {
|
|||
});
|
||||
|
||||
it("executes clear weeds", () => {
|
||||
const wrapper = shallow(<WeedDetector {...props} />);
|
||||
expect(wrapper.state().deletionProgress).toBeUndefined();
|
||||
const wrapper =
|
||||
shallow<WeedDetector>(<WeedDetector {...props} />);
|
||||
expect(wrapper.instance().state.deletionProgress).toBeUndefined();
|
||||
wrapper.find("button").at(1).simulate("click");
|
||||
expect(wrapper.state().deletionProgress).toEqual("Deleting...");
|
||||
expect(wrapper.instance().state.deletionProgress).toEqual("Deleting...");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -41,14 +41,14 @@ describe("<FrontPage />", () => {
|
|||
});
|
||||
|
||||
it("shows forgot password box", () => {
|
||||
const el = mount(<FrontPage />);
|
||||
const el =mount<>(<FrontPage />);
|
||||
expect(el.text()).not.toContain("Reset Password");
|
||||
el.find("a.forgot-password").first().simulate("click");
|
||||
expect(el.text()).toContain("Reset Password");
|
||||
});
|
||||
|
||||
it("shows TOS and Privacy links", () => {
|
||||
const el = mount(<FrontPage />);
|
||||
const el =mount<>(<FrontPage />);
|
||||
["Privacy Policy", "Terms of Use"].map(string =>
|
||||
expect(el.text()).toContain(string));
|
||||
["https://farmbot.io/privacy/", "https://farmbot.io/tos/"]
|
||||
|
@ -57,7 +57,7 @@ describe("<FrontPage />", () => {
|
|||
|
||||
it("submits login: success", async () => {
|
||||
mockAxiosResponse = Promise.resolve({ data: "new data" });
|
||||
const el = mount(<FrontPage />);
|
||||
const el =mount<>(<FrontPage />);
|
||||
el.setState({ email: "foo@bar.io", loginPassword: "password" });
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = el.instance() as any;
|
||||
|
@ -71,7 +71,7 @@ describe("<FrontPage />", () => {
|
|||
|
||||
it("submits login: not verified", async () => {
|
||||
mockAxiosResponse = Promise.reject({ response: { status: 403 } });
|
||||
const el = mount(<FrontPage />);
|
||||
const el =mount<>(<FrontPage />);
|
||||
el.setState({ email: "foo@bar.io", loginPassword: "password" });
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = el.instance() as any;
|
||||
|
@ -88,7 +88,7 @@ describe("<FrontPage />", () => {
|
|||
it("submits login: TOS update", async () => {
|
||||
mockAxiosResponse = Promise.reject({ response: { status: 451 } });
|
||||
window.location.assign = jest.fn();
|
||||
const el = mount(<FrontPage />);
|
||||
const el =mount<>(<FrontPage />);
|
||||
el.setState({ email: "foo@bar.io", loginPassword: "password" });
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = el.instance() as any;
|
||||
|
@ -102,7 +102,7 @@ describe("<FrontPage />", () => {
|
|||
});
|
||||
|
||||
it("submits registration", () => {
|
||||
const el = mount(<FrontPage />);
|
||||
const el =mount<>(<FrontPage />);
|
||||
el.setState({
|
||||
regEmail: "foo@bar.io",
|
||||
regName: "Foo Bar",
|
||||
|
@ -122,7 +122,7 @@ describe("<FrontPage />", () => {
|
|||
});
|
||||
|
||||
it("submits forgot password", () => {
|
||||
const el = mount(<FrontPage />);
|
||||
const el =mount<>(<FrontPage />);
|
||||
el.setState({ email: "foo@bar.io" });
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = el.instance() as any;
|
||||
|
@ -132,7 +132,7 @@ describe("<FrontPage />", () => {
|
|||
});
|
||||
|
||||
it("renders proper panels", () => {
|
||||
const el = mount(<FrontPage />);
|
||||
const el =mount<>(<FrontPage />);
|
||||
el.setState({ activePanel: "resendVerificationEmail" });
|
||||
expect(el.text()).toContain("Account Not Verified");
|
||||
el.setState({ activePanel: "forgotPassword" });
|
||||
|
|
|
@ -22,7 +22,7 @@ describe("resend_verification.tsx - failure case", () => {
|
|||
onGoBack: jest.fn(),
|
||||
email: "foo@bar.com"
|
||||
};
|
||||
const el = mount(<ResendVerification {...props} />);
|
||||
const el =mount<>(<ResendVerification {...props} />);
|
||||
expect.assertions(3);
|
||||
el.find("button").last().simulate("click");
|
||||
const { calls } = props.no.mock;
|
||||
|
|
|
@ -23,7 +23,7 @@ describe("resend_verification.tsx - base case", () => {
|
|||
|
||||
it("fires the `onGoBack()` callback", () => {
|
||||
const p = props();
|
||||
const el = mount(<ResendVerification {...p } />);
|
||||
const el =mount<>(<ResendVerification {...p } />);
|
||||
el.find("button").first().simulate("click");
|
||||
expect(p.no).not.toHaveBeenCalled();
|
||||
expect(p.ok).not.toHaveBeenCalled();
|
||||
|
@ -32,7 +32,7 @@ describe("resend_verification.tsx - base case", () => {
|
|||
|
||||
it("fires the `ok()` callback", (done) => {
|
||||
const p = props();
|
||||
const el = mount(<ResendVerification {...p } />);
|
||||
const el =mount<>(<ResendVerification {...p } />);
|
||||
expect.assertions(3);
|
||||
el.find("button").last().simulate("click");
|
||||
const { calls } = p.ok.mock;
|
||||
|
|
|
@ -56,7 +56,7 @@ describe("<Logs />", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<Logs {...fakeProps()} />);
|
||||
const wrapper =mount<>(<Logs {...fakeProps()} />);
|
||||
["Logs", ToolTips.LOGS, "Type", "Message", "Time", "Info",
|
||||
"Fake log message 1", "Success", "Fake log message 2"]
|
||||
.map(string =>
|
||||
|
@ -69,12 +69,12 @@ describe("<Logs />", () => {
|
|||
it("shows message when logs are loading", () => {
|
||||
const p = fakeProps();
|
||||
p.logs[0].body.message = "";
|
||||
const wrapper = mount(<Logs {...p} />);
|
||||
const wrapper =mount<>(<Logs {...p} />);
|
||||
expect(wrapper.text().toLowerCase()).toContain("loading");
|
||||
});
|
||||
|
||||
it("filters logs", () => {
|
||||
const wrapper = mount(<Logs {...fakeProps()} />);
|
||||
const wrapper =mount<>(<Logs {...fakeProps()} />);
|
||||
wrapper.setState({ info: 0 });
|
||||
expect(wrapper.text()).not.toContain("Fake log message 1");
|
||||
const filterBtn = wrapper.find("button").first();
|
||||
|
@ -88,7 +88,7 @@ describe("<Logs />", () => {
|
|||
const notShownMessage = "This log should not be shown.";
|
||||
p.logs[0].body.message = notShownMessage;
|
||||
p.logs[0].body.type = "info";
|
||||
const wrapper = mount(<Logs {...p} />);
|
||||
const wrapper =mount<>(<Logs {...p} />);
|
||||
wrapper.setState({ info: 0 });
|
||||
expect(wrapper.text()).not.toContain(notShownMessage);
|
||||
});
|
||||
|
@ -101,7 +101,7 @@ describe("<Logs />", () => {
|
|||
p.logs[1].body.x = 0;
|
||||
p.logs[1].body.y = 1;
|
||||
p.logs[1].body.z = 2;
|
||||
const wrapper = mount(<Logs {...p} />);
|
||||
const wrapper =mount<>(<Logs {...p} />);
|
||||
expect(wrapper.text()).toContain("Unknown");
|
||||
expect(wrapper.text()).toContain("0, 1, 2");
|
||||
});
|
||||
|
@ -109,18 +109,18 @@ describe("<Logs />", () => {
|
|||
it("shows verbosity", () => {
|
||||
const p = fakeProps();
|
||||
p.logs[0].body.verbosity = -999;
|
||||
const wrapper = mount(<Logs {...p} />);
|
||||
const wrapper =mount<>(<Logs {...p} />);
|
||||
expect(wrapper.text()).toContain(-999);
|
||||
});
|
||||
|
||||
it("loads filter setting", () => {
|
||||
mockStorj[NumericSetting.warn_log] = 3;
|
||||
const wrapper = mount(<Logs {...fakeProps()} />);
|
||||
expect(wrapper.state().warn).toEqual(3);
|
||||
const wrapper = mount<Logs>(<Logs {...fakeProps()} />);
|
||||
expect(wrapper.instance().state.warn).toEqual(3);
|
||||
});
|
||||
|
||||
it("shows overall filter status", () => {
|
||||
const wrapper = mount(<Logs {...fakeProps()} />);
|
||||
const wrapper =mount<>(<Logs {...fakeProps()} />);
|
||||
wrapper.setState({
|
||||
success: 3, busy: 3, warn: 3, error: 3, info: 3, fun: 3, debug: 3
|
||||
});
|
||||
|
@ -131,23 +131,23 @@ describe("<Logs />", () => {
|
|||
|
||||
it("toggles filter", () => {
|
||||
mockStorj[NumericSetting.warn_log] = 3;
|
||||
const wrapper = mount(<Logs {...fakeProps()} />);
|
||||
const wrapper = mount<Logs>(<Logs {...fakeProps()} />);
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = wrapper.instance() as any;
|
||||
expect(wrapper.state().warn).toEqual(3);
|
||||
expect(wrapper.instance().state.warn).toEqual(3);
|
||||
instance.toggle("warn")();
|
||||
expect(wrapper.state().warn).toEqual(0);
|
||||
expect(wrapper.instance().state.warn).toEqual(0);
|
||||
instance.toggle("warn")();
|
||||
expect(wrapper.state().warn).toEqual(1);
|
||||
expect(wrapper.instance().state.warn).toEqual(1);
|
||||
});
|
||||
|
||||
it("sets filter", () => {
|
||||
mockStorj[NumericSetting.warn_log] = 3;
|
||||
const wrapper = mount(<Logs {...fakeProps()} />);
|
||||
const wrapper = mount<Logs>(<Logs {...fakeProps()} />);
|
||||
// tslint:disable-next-line:no-any
|
||||
const instance = wrapper.instance() as any;
|
||||
expect(wrapper.state().warn).toEqual(3);
|
||||
expect(wrapper.instance().state.warn).toEqual(3);
|
||||
instance.setFilterLevel("warn")(2);
|
||||
expect(wrapper.state().warn).toEqual(2);
|
||||
expect(wrapper.instance().state.warn).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ describe("<LogsFilterMenu />", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<LogsFilterMenu {...fakeProps()} />);
|
||||
const wrapper =mount<>(<LogsFilterMenu {...fakeProps()} />);
|
||||
logTypes.map(string =>
|
||||
expect(wrapper.text().toLowerCase())
|
||||
.toContain(string.toLowerCase()));
|
||||
|
@ -34,7 +34,7 @@ describe("<LogsFilterMenu />", () => {
|
|||
const p = fakeProps();
|
||||
p.toggle = (x) => () => toggle(x);
|
||||
p.setFilterLevel = (x) => () => setFilterLevel(x);
|
||||
const wrapper = mount(<LogsFilterMenu {...p} />);
|
||||
const wrapper =mount<>(<LogsFilterMenu {...p} />);
|
||||
wrapper.find("button").at(2).simulate("click");
|
||||
expect(toggle).toHaveBeenCalledWith("success");
|
||||
});
|
||||
|
@ -42,7 +42,7 @@ describe("<LogsFilterMenu />", () => {
|
|||
it("shows filter status", () => {
|
||||
fakeState.debug = 3;
|
||||
fakeState.success = 0;
|
||||
const wrapper = mount(<LogsFilterMenu {...fakeProps()} />);
|
||||
const wrapper =mount<>(<LogsFilterMenu {...fakeProps()} />);
|
||||
const toggles = wrapper.find("button");
|
||||
expect(toggles.last().hasClass("green")).toBeTruthy();
|
||||
expect(toggles.at(2).hasClass("red")).toBeTruthy();
|
||||
|
@ -52,7 +52,7 @@ describe("<LogsFilterMenu />", () => {
|
|||
const setFilterLevel = jest.fn();
|
||||
const p = fakeProps();
|
||||
p.setFilterLevel = (x) => () => setFilterLevel(x);
|
||||
const wrapper = mount(<LogsFilterMenu {...p} />);
|
||||
const wrapper =mount<>(<LogsFilterMenu {...p} />);
|
||||
clickButton(wrapper, 0, "max");
|
||||
logTypes.map(logType =>
|
||||
expect(setFilterLevel).toHaveBeenCalledWith(logType));
|
||||
|
|
|
@ -52,7 +52,7 @@ describe("<LogsSettingsMenu />", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<LogsSettingsMenu {...fakeProps() } />);
|
||||
const wrapper =mount<>(<LogsSettingsMenu {...fakeProps() } />);
|
||||
["begin", "steps", "complete"].map(string =>
|
||||
expect(wrapper.text().toLowerCase()).toContain(string));
|
||||
});
|
||||
|
@ -60,7 +60,7 @@ describe("<LogsSettingsMenu />", () => {
|
|||
function testSettingToggle(setting: ConfigurationName, position: number) {
|
||||
it("toggles setting", () => {
|
||||
bot.hardware.configuration[setting] = false;
|
||||
const wrapper = mount(<LogsSettingsMenu {...fakeProps() } />);
|
||||
const wrapper =mount<>(<LogsSettingsMenu {...fakeProps() } />);
|
||||
wrapper.find("button").at(position).simulate("click");
|
||||
expect(mockDevice.updateConfig)
|
||||
.toHaveBeenCalledWith({ [setting]: true });
|
||||
|
@ -77,7 +77,7 @@ describe("<LogsSettingsMenu />", () => {
|
|||
const p = fakeProps();
|
||||
const setFilterLevel = jest.fn();
|
||||
p.setFilterLevel = () => setFilterLevel;
|
||||
const wrapper = mount(<LogsSettingsMenu {...p} />);
|
||||
const wrapper =mount<>(<LogsSettingsMenu {...p} />);
|
||||
mockStorj[NumericSetting.busy_log] = 0;
|
||||
wrapper.find("button").at(0).simulate("click");
|
||||
expect(setFilterLevel).toHaveBeenCalledWith(2);
|
||||
|
|
|
@ -4,7 +4,7 @@ import { AdditionalMenu } from "../additional_menu";
|
|||
|
||||
describe("AdditionalMenu", () => {
|
||||
it("renders the account menu", () => {
|
||||
const wrapper = mount(<AdditionalMenu
|
||||
const wrapper =mount<>(<AdditionalMenu
|
||||
logout={jest.fn()}
|
||||
close={jest.fn()} />);
|
||||
const text = wrapper.text();
|
||||
|
|
|
@ -21,7 +21,7 @@ describe("NavBar", () => {
|
|||
});
|
||||
|
||||
it("closes nav menu", () => {
|
||||
const wrapper = shallow(<NavBar
|
||||
const wrapper = shallow<NavBar>(<NavBar
|
||||
timeOffset={0}
|
||||
consistent={true}
|
||||
logs={[]}
|
||||
|
@ -30,8 +30,8 @@ describe("NavBar", () => {
|
|||
dispatch={jest.fn()} />);
|
||||
const link = wrapper.find("Link").first();
|
||||
link.simulate("click");
|
||||
expect(wrapper.state().mobileMenuOpen).toBeFalsy();
|
||||
expect(wrapper.instance().state.mobileMenuOpen).toBeFalsy();
|
||||
link.simulate("click");
|
||||
expect(wrapper.state().mobileMenuOpen).toBeFalsy();
|
||||
expect(wrapper.instance().state.mobileMenuOpen).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -50,7 +50,7 @@ describe("<TickerList />", () => {
|
|||
}
|
||||
|
||||
it("shows log message and datetime", () => {
|
||||
const wrapper = mount(<TickerList {...fakeProps()} />);
|
||||
const wrapper =mount<>(<TickerList {...fakeProps()} />);
|
||||
const labels = wrapper.find("label");
|
||||
expect(labels.length).toEqual(2);
|
||||
expect(labels.at(0).text()).toContain("Farmbot is up and Running!");
|
||||
|
@ -61,7 +61,7 @@ describe("<TickerList />", () => {
|
|||
it("shows empty log message", () => {
|
||||
const p = fakeProps();
|
||||
p.logs = [];
|
||||
const wrapper = mount(<TickerList {...p} />);
|
||||
const wrapper =mount<>(<TickerList {...p} />);
|
||||
const labels = wrapper.find("label");
|
||||
expect(labels.length).toEqual(2);
|
||||
expect(labels.at(0).text()).toContain("No logs yet.");
|
||||
|
@ -70,7 +70,7 @@ describe("<TickerList />", () => {
|
|||
it("shows 'loading' log message", () => {
|
||||
const p = fakeProps();
|
||||
p.logs[0].body.message = "";
|
||||
const wrapper = mount(<TickerList {...p} />);
|
||||
const wrapper =mount<>(<TickerList {...p} />);
|
||||
const labels = wrapper.find("label");
|
||||
expect(labels.length).toEqual(2);
|
||||
expect(labels.at(0).text()).toContain("Loading");
|
||||
|
@ -79,7 +79,7 @@ describe("<TickerList />", () => {
|
|||
it("opens ticker", () => {
|
||||
const p = fakeProps();
|
||||
p.tickerListOpen = true;
|
||||
const wrapper = mount(<TickerList {...p} />);
|
||||
const wrapper =mount<>(<TickerList {...p} />);
|
||||
const labels = wrapper.find("label");
|
||||
expect(labels.length).toEqual(5);
|
||||
expect(labels.at(0).text()).toContain("Farmbot is up and Running!");
|
||||
|
@ -95,7 +95,7 @@ describe("<TickerList />", () => {
|
|||
.map(logType => mockStorj[logType + "_log"] = 0);
|
||||
const p = fakeProps();
|
||||
p.logs[0].body.verbosity = 1;
|
||||
const wrapper = mount(<TickerList {...p} />);
|
||||
const wrapper =mount<>(<TickerList {...p} />);
|
||||
const labels = wrapper.find("label");
|
||||
expect(labels.length).toEqual(2);
|
||||
expect(labels.at(0).text())
|
||||
|
|
|
@ -16,7 +16,7 @@ describe("<PasswordReset/>", () => {
|
|||
|
||||
it("resets the users password", (done) => {
|
||||
expect.assertions(5);
|
||||
const el = mount(<PasswordReset />);
|
||||
const el =mount<>(<PasswordReset />);
|
||||
el.setState({
|
||||
password: "knocknock",
|
||||
passwordConfirmation: "knocknock",
|
||||
|
@ -42,7 +42,7 @@ describe("<PasswordReset/>", () => {
|
|||
});
|
||||
|
||||
it("Has a form set()ter", () => {
|
||||
const el = mount(<PasswordReset />);
|
||||
const el =mount<>(<PasswordReset />);
|
||||
const i = el.instance() as PasswordReset;
|
||||
const field = "password";
|
||||
const value = "password123";
|
||||
|
|
|
@ -36,7 +36,7 @@ describe("<Regimens />", () => {
|
|||
}
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<Regimens {...fakeProps()} />);
|
||||
const wrapper =mount<>(<Regimens {...fakeProps()} />);
|
||||
["Regimens", "Regimen Editor", "Scheduler"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ describe("<Regimens />", () => {
|
|||
it("scheduler is hidden", () => {
|
||||
const p = fakeProps();
|
||||
p.current = undefined;
|
||||
const wrapper = mount(<Regimens {...p} />);
|
||||
const wrapper =mount<>(<Regimens {...p} />);
|
||||
expect(wrapper.text()).not.toContain("Scheduler");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ import { AddButton } from "../add_button";
|
|||
describe("<AddButton />", () => {
|
||||
it("renders an add button when active", () => {
|
||||
const props: AddButtonProps = { active: true, click: jest.fn() };
|
||||
const wrapper = mount(<AddButton {...props} />);
|
||||
const wrapper =mount<>(<AddButton {...props} />);
|
||||
const button = wrapper.find("button");
|
||||
["green", "add"].map(klass => {
|
||||
expect(button.hasClass(klass)).toBeTruthy();
|
||||
|
@ -18,7 +18,7 @@ describe("<AddButton />", () => {
|
|||
|
||||
it("renders a <div> when inactive", () => {
|
||||
const props: AddButtonProps = { active: false, click: jest.fn() };
|
||||
const wrapper = mount(<AddButton {...props} />);
|
||||
const wrapper =mount<>(<AddButton {...props} />);
|
||||
expect(wrapper.html()).toEqual("<div></div>");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ describe("<BulkScheduler />", () => {
|
|||
}
|
||||
|
||||
it("renders with sequence selected", () => {
|
||||
const wrapper = mount(<BulkScheduler {...fakeProps()} />);
|
||||
const wrapper =mount<>(<BulkScheduler {...fakeProps()} />);
|
||||
const buttons = wrapper.find("button");
|
||||
expect(buttons.length).toEqual(6);
|
||||
["Sequence", "Fake Sequence", "Time",
|
||||
|
@ -45,7 +45,7 @@ describe("<BulkScheduler />", () => {
|
|||
it("renders without sequence selected", () => {
|
||||
const p = fakeProps();
|
||||
p.selectedSequence = undefined;
|
||||
const wrapper = mount(<BulkScheduler {...p} />);
|
||||
const wrapper =mount<>(<BulkScheduler {...p} />);
|
||||
["Sequence", "None", "Time"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ describe("<WeekGrid />", () => {
|
|||
|
||||
it("renders", () => {
|
||||
const props: WeekGridProps = { weeks, dispatch: jest.fn() };
|
||||
const wrapper = mount(<WeekGrid {...props} />);
|
||||
const wrapper =mount<>(<WeekGrid {...props} />);
|
||||
const buttons = wrapper.find("button");
|
||||
expect(buttons.length).toEqual(4);
|
||||
["Days", "Week 1", "1234567"].map(string =>
|
||||
|
@ -33,7 +33,7 @@ describe("<WeekGrid />", () => {
|
|||
|
||||
function checkAction(position: number, text: string, type: Actions) {
|
||||
const props: WeekGridProps = { weeks, dispatch: jest.fn() };
|
||||
const wrapper = mount(<WeekGrid {...props} />);
|
||||
const wrapper =mount<>(<WeekGrid {...props} />);
|
||||
const button = wrapper.find("button").at(position);
|
||||
expect(button.text().toLowerCase()).toContain(text.toLowerCase());
|
||||
button.simulate("click");
|
||||
|
|
|
@ -28,13 +28,13 @@ describe("<ActiveEditor />", () => {
|
|||
};
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = mount(<ActiveEditor {...props} />);
|
||||
const wrapper =mount<>(<ActiveEditor {...props} />);
|
||||
["Day", "Item 0", "10:00"].map(string =>
|
||||
expect(wrapper.text()).toContain(string));
|
||||
});
|
||||
|
||||
it("removes regimen item", () => {
|
||||
const wrapper = mount(<ActiveEditor {...props} />);
|
||||
const wrapper =mount<>(<ActiveEditor {...props} />);
|
||||
wrapper.find("i").simulate("click");
|
||||
expect(props.dispatch).toHaveBeenCalledWith({
|
||||
payload: {
|
||||
|
|
|
@ -14,7 +14,7 @@ describe("Copy button", () => {
|
|||
it("Initializes a new regimen on click", () => {
|
||||
const dispatch = jest.fn();
|
||||
const regimen = fakeRegimen();
|
||||
const el = mount(<CopyButton dispatch={dispatch} regimen={regimen} />);
|
||||
const el =mount<>(<CopyButton dispatch={dispatch} regimen={regimen} />);
|
||||
expect(el.find("button").length).toBe(1);
|
||||
el.simulate("click");
|
||||
expect(dispatch).toHaveBeenCalledTimes(1);
|
||||
|
@ -34,7 +34,7 @@ describe("Copy button", () => {
|
|||
it("Render a button when given a regimen", () => {
|
||||
const dispatch = jest.fn();
|
||||
const regimen = fakeRegimen();
|
||||
const el = mount(<CopyButton dispatch={dispatch} regimen={regimen} />);
|
||||
const el =mount<>(<CopyButton dispatch={dispatch} regimen={regimen} />);
|
||||
expect(el.find("button").length).toBe(1);
|
||||
el.simulate("click");
|
||||
expect(dispatch).toHaveBeenCalledTimes(1);
|
||||
|
@ -42,7 +42,7 @@ describe("Copy button", () => {
|
|||
|
||||
it("renders nothing if not given a regimen", () => {
|
||||
const dispatch = jest.fn();
|
||||
const el = mount(<CopyButton dispatch={dispatch} />);
|
||||
const el =mount<>(<CopyButton dispatch={dispatch} />);
|
||||
expect(el.find("button").length).toBe(0);
|
||||
el.simulate("click");
|
||||
expect(dispatch).not.toHaveBeenCalled();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue