Farmbot-Web-App/frontend/sequences/locals_list/__tests__/location_form_list_test.ts

61 lines
1.5 KiB
TypeScript
Raw Normal View History

2019-01-13 17:16:22 -07:00
import { locationFormList, dropDownName } from "../location_form_list";
2017-10-12 21:50:02 -06:00
import { fakeResourceIndex } from "../test_helpers";
2019-01-13 16:43:12 -07:00
describe("locationFormList()", () => {
2017-10-12 21:50:02 -06:00
it("returns dropdown list", () => {
2019-01-13 16:43:12 -07:00
const items = locationFormList(fakeResourceIndex(), []);
2019-04-09 22:00:03 -06:00
const coordinate = items[0];
expect(coordinate).toEqual({
headingId: "Coordinate",
label: "Custom Coordinates",
value: "",
});
const toolHeading = items[1];
expect(toolHeading).toEqual({
headingId: "Tool",
label: "Tools",
value: 0,
heading: true,
});
2019-04-09 22:00:03 -06:00
const tool = items[2];
expect(tool).toEqual({
headingId: "Tool",
2018-12-20 20:18:10 -07:00
label: "Generic tool (100, 200, 300)",
value: "1",
});
2019-04-09 22:00:03 -06:00
const plantHeading = items[3];
expect(plantHeading).toEqual({
headingId: "Plant",
label: "Plants",
value: 0,
heading: true,
});
2019-04-09 22:00:03 -06:00
const plant = items[4];
2017-10-12 21:50:02 -06:00
expect(plant).toEqual({
headingId: "Plant",
label: "Plant 1 (1, 2, 3)",
2017-10-12 21:50:02 -06:00
value: "1"
});
2019-04-09 22:00:03 -06:00
const pointHeading = items[6];
expect(pointHeading).toEqual({
headingId: "GenericPointer",
label: "Map Points",
value: 0,
heading: true,
});
2019-04-09 22:00:03 -06:00
const point = items[7];
2017-10-12 21:50:02 -06:00
expect(point).toEqual({
headingId: "GenericPointer",
label: "Point 1 (10, 20, 30)",
2017-10-12 21:50:02 -06:00
value: "2"
});
});
});
describe("dropDownName()", () => {
it("returns label", () => {
const label = dropDownName("Plant 1", { x: 10, y: 20, z: 30 });
expect(label).toEqual("Plant 1 (10, 20, 30)");
2017-10-12 21:50:02 -06:00
});
});