Finish action_list.ts tests
This commit is contained in:
parent
7c8b2f6157
commit
9997a98c97
|
@ -1,19 +1,33 @@
|
|||
import { actionList } from "../action_list";
|
||||
import { resourceUpdate } from "../assertion_support";
|
||||
import { buildResourceIndex } from "../../../../__test_support__/resource_index_builder";
|
||||
import { actionList, PLANT_OPTIONS } from "../action_list";
|
||||
import { betterMerge } from "../../../../util";
|
||||
import { fakeTool, fakePlant } from "../../../../__test_support__/fake_state/resources";
|
||||
import { resourceUpdate } from "../assertion_support";
|
||||
import {
|
||||
fakeTool,
|
||||
fakePlant
|
||||
} from "../../../../__test_support__/fake_state/resources";
|
||||
import {
|
||||
buildResourceIndex
|
||||
} from "../../../../__test_support__/resource_index_builder";
|
||||
|
||||
describe("actionList()", () => {
|
||||
it("Provides a list of tool mount actions", () => {
|
||||
const myIndex = () => buildResourceIndex([
|
||||
betterMerge(fakeTool(), { body: { name: "T1", id: 1 } }),
|
||||
fakePlant(),
|
||||
betterMerge(fakeTool(), { body: { name: "T2", id: 2 } }),
|
||||
betterMerge(fakeTool(), { body: { name: "T3", id: undefined } }),
|
||||
]);
|
||||
|
||||
it("uses args.resource_type if DropDownItem is undefined", () => {
|
||||
const step = resourceUpdate({ resource_type: "Plant" });
|
||||
const { index } = myIndex();
|
||||
const result = actionList(undefined, step, index);
|
||||
expect(result).toEqual(PLANT_OPTIONS);
|
||||
});
|
||||
|
||||
it("provides a list of tool mount actions", () => {
|
||||
const ddi = { label: "test case", value: 1, headingId: "Device" };
|
||||
const step = resourceUpdate({});
|
||||
const { index } = buildResourceIndex([
|
||||
betterMerge(fakeTool(), { body: { name: "T1", id: 1 } }),
|
||||
fakePlant(),
|
||||
betterMerge(fakeTool(), { body: { name: "T2", id: 2 } }),
|
||||
betterMerge(fakeTool(), { body: { name: "T3", id: undefined } }),
|
||||
]);
|
||||
const { index } = myIndex();
|
||||
const result = actionList(ddi, step, index);
|
||||
expect(result.length).toBe(3);
|
||||
const labels = result.map(x => x.label);
|
||||
|
@ -21,4 +35,12 @@ describe("actionList()", () => {
|
|||
expect(labels).toContain("Mounted to: T1");
|
||||
expect(labels).toContain("Mounted to: T2");
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ import { selectAllTools } from "../../../resources/selectors";
|
|||
const DEFAULT = "Default";
|
||||
const DISMOUNT = { label: "Not Mounted", value: 0 };
|
||||
export const MOUNTED_TO = "Mounted to:";
|
||||
const PLANT_OPTIONS = [
|
||||
export const PLANT_OPTIONS = [
|
||||
{ label: "Planned", value: "planned" },
|
||||
{ label: "Planted", value: "planted" },
|
||||
{ label: "Harvested", value: "harvested" },
|
||||
|
|
Loading…
Reference in a new issue