Skip to content

Commit

Permalink
remove BoxLeds from toggle_pin command
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielburnworth committed Jun 9, 2022
1 parent 9dc9665 commit 1d4e5df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Expand Up @@ -132,6 +132,20 @@ describe("pinsAsDropdowns()", () => {
const result = PinSupport.pinsAsDropdowns("read_pin")(ri.index, true);
expect(JSON.stringify(result)).toContain("Pin 13");
});

it("toggle_pin: displays peripherals and sensors", () => {
const p = fakePeripheral();
p.body.label = "displayed peripheral";
const ri = buildResourceIndex([p]);
const result = PinSupport.pinsAsDropdowns("toggle_pin")(ri.index, true);
expect(JSON.stringify(result)).toContain("displayed peripheral");
});

it("toggle_pin: displays pins", () => {
const ri = buildResourceIndex([]);
const result = PinSupport.pinsAsDropdowns("toggle_pin")(ri.index, true);
expect(JSON.stringify(result)).toContain("Pin 13");
});
});

describe("findByPinNumber()", () => {
Expand Down
Expand Up @@ -123,6 +123,14 @@ const pinsAsDropDownsWritePin = (
];
};

const pinsAsDropDownsTogglePin = (
resources: ResourceIndex, showPins: boolean,
): DropDownItem[] =>
[
...peripheralsAsDropDowns(resources),
...(showPins ? pinDropdowns(n => n) : []),
];

const pinsAsDropDownsReadPin = (
resources: ResourceIndex, showPins: boolean,
): DropDownItem[] =>
Expand All @@ -136,9 +144,8 @@ export const pinsAsDropdowns =
(kind: "read_pin" | "write_pin" | "toggle_pin") => {
switch (kind) {
case "read_pin": return pinsAsDropDownsReadPin;
case "write_pin":
case "toggle_pin":
return pinsAsDropDownsWritePin;
case "write_pin": return pinsAsDropDownsWritePin;
case "toggle_pin": return pinsAsDropDownsTogglePin;
}

};
Expand Down

0 comments on commit 1d4e5df

Please sign in to comment.