Farmbot-Web-App/frontend/farm_designer/map/layers/farmbot/__tests__/index_test.tsx

48 lines
1.6 KiB
TypeScript
Raw Normal View History

2017-10-31 23:14:21 -06:00
import * as React from "react";
import { VirtualFarmBot } from "../index";
import { shallow } from "enzyme";
2018-10-25 18:02:54 -06:00
import { VirtualFarmBotProps } from "../../../interfaces";
import {
fakeMapTransformProps
2018-10-25 18:02:54 -06:00
} from "../../../../../__test_support__/map_transform_props";
2020-02-28 09:34:28 -07:00
import { BotFigure } from "../bot_figure";
2017-10-31 23:14:21 -06:00
describe("<VirtualFarmBot/>", () => {
function fakeProps(): VirtualFarmBotProps {
return {
botLocationData: {
position: { x: 0, y: 0, z: 0 },
scaled_encoders: { x: undefined, y: undefined, z: undefined },
raw_encoders: { x: undefined, y: undefined, z: undefined },
},
2018-04-12 21:36:16 -06:00
mapTransformProps: fakeMapTransformProps(),
2017-11-01 02:07:02 -06:00
plantAreaOffset: { x: 100, y: 100 },
peripherals: [],
eStopStatus: false,
getConfigValue: () => true,
2020-02-20 19:38:50 -07:00
mountedToolName: undefined,
2017-10-31 23:14:21 -06:00
};
}
it("shows bot position", () => {
const p = fakeProps();
p.getConfigValue = () => false;
const wrapper = shallow(<VirtualFarmBot {...p} />);
2020-02-28 09:34:28 -07:00
const figures = wrapper.find(BotFigure);
2017-10-31 23:14:21 -06:00
expect(figures.length).toEqual(1);
2020-02-28 09:34:28 -07:00
expect(figures.last().props().figureName).toEqual("motor-position");
2017-10-31 23:14:21 -06:00
});
it("shows trail", () => {
2018-04-12 21:36:16 -06:00
const wrapper = shallow(<VirtualFarmBot {...fakeProps()} />);
2017-10-31 23:14:21 -06:00
expect(wrapper.find("BotTrail").length).toEqual(1);
});
it("shows encoder position", () => {
2018-04-12 21:36:16 -06:00
const wrapper = shallow(<VirtualFarmBot {...fakeProps()} />);
2020-02-28 09:34:28 -07:00
const figures = wrapper.find(BotFigure);
2017-10-31 23:14:21 -06:00
expect(figures.length).toEqual(2);
2020-02-28 09:34:28 -07:00
expect(figures.last().props().figureName).toEqual("encoder-position");
2017-10-31 23:14:21 -06:00
});
});