From e56e620f549a7b9ad736ceff9547953f6e7f4f42 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Mon, 23 Sep 2019 22:24:03 +0200 Subject: [PATCH] Add test case for https://github.com/Koenkk/zigbee2mqtt/issues/1997 --- test/controller.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/controller.test.js b/test/controller.test.js index 6a49d59f..67c8bcf6 100644 --- a/test/controller.test.js +++ b/test/controller.test.js @@ -222,6 +222,16 @@ describe('Controller', () => { expect(MQTT.publish).toHaveBeenCalledWith("zigbee2mqtt/bridge/log", '{"type":"device_connected","message":{"friendly_name":"bulb"}}', {"retain": false, qos: 0}, expect.any(Function)); }); + it('Shouldnt crash when two device join events are received', async () => { + await controller.start(); + const device = zigbeeHerdsman.devices.bulb; + const payload = {device}; + zigbeeHerdsman.events.deviceJoined(payload); + zigbeeHerdsman.events.deviceJoined(payload); + await flushPromises(); + expect(MQTT.publish).toHaveBeenCalledWith("zigbee2mqtt/bridge/log", '{"type":"device_connected","message":{"friendly_name":"bulb"}}', {"retain": false, qos: 0}, expect.any(Function)); + }); + it('On zigbee deviceInterview started', async () => { await controller.start(); const device = zigbeeHerdsman.devices.bulb;