Farmbot-Web-App/frontend/sequences/step_tiles/mark_as/__tests__/action_list_test.ts

56 lines
2.1 KiB
TypeScript
Raw Normal View History

2018-09-11 15:53:27 -06:00
import { actionList } from "../action_list";
2018-09-11 13:17:01 -06:00
import { resourceUpdate, markAsResourceFixture } from "../assertion_support";
2018-09-11 07:18:18 -06:00
import {
2020-02-28 09:35:32 -07:00
buildResourceIndex,
2018-09-11 07:18:18 -06:00
} from "../../../../__test_support__/resource_index_builder";
2018-09-11 15:53:27 -06:00
import { PLANT_OPTIONS } from "../constants";
2018-09-10 16:38:58 -06:00
describe("actionList()", () => {
2018-09-11 07:18:18 -06:00
it("uses args.resource_type if DropDownItem is undefined", () => {
const step = resourceUpdate({ resource_type: "Plant" });
2018-09-11 13:17:01 -06:00
const { index } = markAsResourceFixture();
2018-09-11 07:18:18 -06:00
const result = actionList(undefined, step, index);
expect(result).toEqual(PLANT_OPTIONS());
2018-09-11 07:18:18 -06:00
});
it("provides a list of tool mount actions", () => {
2018-09-10 16:38:58 -06:00
const ddi = { label: "test case", value: 1, headingId: "Device" };
const step = resourceUpdate({});
2018-09-11 13:17:01 -06:00
const { index } = markAsResourceFixture();
2018-09-10 16:38:58 -06:00
const result = actionList(ddi, step, index);
expect(result.length).toBe(3);
const labels = result.map(x => x.label);
expect(labels).toContain("Not Mounted");
expect(labels).toContain("Mounted to: T1");
expect(labels).toContain("Mounted to: T2");
});
2018-09-11 07:18:18 -06:00
2018-09-11 12:59:47 -06:00
it("provides a list of generic pointer actions", () => {
const ddi = { label: "test case", value: 1, headingId: "GenericPointer" };
const step = resourceUpdate({});
2018-09-11 13:17:01 -06:00
const { index } = markAsResourceFixture();
2018-09-11 12:59:47 -06:00
const result = actionList(ddi, step, index);
expect(result.length).toBe(1);
const labels = result.map(x => x.label);
expect(labels).toContain("Removed");
});
it("provides a list of weed pointer actions", () => {
const ddi = { label: "test case", value: 1, headingId: "Weed" };
const step = resourceUpdate({});
const { index } = markAsResourceFixture();
const result = actionList(ddi, step, index);
expect(result.length).toBe(1);
const labels = result.map(x => x.label);
expect(labels).toContain("Removed");
});
2018-09-11 07:18:18 -06:00
it("returns an empty list for all other options", () => {
const ddi = { label: "test case", value: 1, headingId: "USB Cables" };
const step = resourceUpdate({});
const { index } = buildResourceIndex([]);
const result = actionList(ddi, step, index);
expect(result.length).toBe(0);
});
2018-09-10 16:38:58 -06:00
});