diff --git a/webpack/controls/peripherals/__tests__/index_test.tsx b/webpack/controls/peripherals/__tests__/index_test.tsx index 8e2f0cc18..a9c15864c 100644 --- a/webpack/controls/peripherals/__tests__/index_test.tsx +++ b/webpack/controls/peripherals/__tests__/index_test.tsx @@ -71,4 +71,24 @@ describe("", () => { save.simulate("click"); expect(p.dispatch).toHaveBeenCalled(); }); + + it("adds empty peripheral", () => { + const p = fakeProps(); + const wrapper = mount(); + wrapper.setState({ isEditing: true }); + const add = wrapper.find("button").at(2); + expect(add.text()).toEqual(""); + add.simulate("click"); + expect(p.dispatch).toHaveBeenCalled(); + }); + + it("adds farmduino peripherals", () => { + const p = fakeProps(); + const wrapper = mount(); + wrapper.setState({ isEditing: true }); + const add = wrapper.find("button").at(3); + expect(add.text()).toEqual("Farmduino"); + add.simulate("click"); + expect(p.dispatch).toHaveBeenCalledTimes(5); + }); }); diff --git a/webpack/controls/peripherals/index.tsx b/webpack/controls/peripherals/index.tsx index 6d2371aa0..0e03851e7 100644 --- a/webpack/controls/peripherals/index.tsx +++ b/webpack/controls/peripherals/index.tsx @@ -65,6 +65,22 @@ export class Peripherals extends React.Component { + function newPeripheral(pin: number, label: string) { + dispatch(init({ + uuid: "WILL_BE_CHANGED_BY_REDUCER", + specialStatus: SpecialStatus.SAVED, + kind: "Peripheral", + body: { pin, label } + })); + } + newPeripheral(7, "Lighting"); + newPeripheral(8, "Water"); + newPeripheral(9, "Vacuum"); + newPeripheral(10, "Peripheral 4"); + newPeripheral(12, "Peripheral 5"); + } + render() { const { dispatch, peripherals } = this.props; const { isEditing } = this.state; @@ -91,6 +107,14 @@ export class Peripherals extends React.Component { dispatch(init(this.emptyPeripheral())); }}> + {this.showPins()}