2020-04-21 15:37:08 -06:00
|
|
|
import { fakeMarkAsProps } from "../test_support";
|
2018-09-11 14:35:02 -06:00
|
|
|
import { commitStepChanges } from "../commit_step_changes";
|
2020-04-21 15:37:08 -06:00
|
|
|
import { UpdateResource, TaggedSequence } from "farmbot";
|
2018-09-11 14:35:02 -06:00
|
|
|
import { Actions } from "../../../../constants";
|
2018-09-12 15:09:40 -06:00
|
|
|
import { unpackUUID } from "../../../../util";
|
2018-09-11 14:35:02 -06:00
|
|
|
|
|
|
|
describe("commitSelection", () => {
|
|
|
|
it("commits changes in a <MarkAs/> component", () => {
|
|
|
|
const p = fakeMarkAsProps();
|
|
|
|
const results = commitStepChanges({
|
|
|
|
nextAction: { label: "X", value: "some_action" },
|
|
|
|
nextResource: undefined,
|
2020-04-21 15:37:08 -06:00
|
|
|
step: p.currentStep as UpdateResource,
|
2018-09-11 14:35:02 -06:00
|
|
|
index: p.index,
|
|
|
|
sequence: p.currentSequence
|
|
|
|
});
|
|
|
|
expect(results.type).toBe(Actions.OVERWRITE_RESOURCE);
|
|
|
|
const { payload } = results;
|
2018-09-12 15:09:40 -06:00
|
|
|
expect(unpackUUID(payload.uuid).kind).toBe("Sequence");
|
2018-09-11 14:35:02 -06:00
|
|
|
const s = payload.update as TaggedSequence["body"];
|
|
|
|
expect(s.kind).toBe("sequence");
|
2020-04-21 15:37:08 -06:00
|
|
|
const step = (s.body || [])[0] as UpdateResource;
|
|
|
|
expect(step.body?.[0].args.value).toBe("some_action");
|
2018-09-11 14:35:02 -06:00
|
|
|
});
|
|
|
|
});
|