diff --git a/test/controller.test.js b/test/controller.test.js index 6a49d59f7..67c8bcf67 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;