mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-27 21:20:03 +00:00
bridge/request/options: fix exception on null value.
This commit is contained in:
@@ -163,7 +163,7 @@ class Bridge extends Extension {
|
||||
const beforeValue = before[key];
|
||||
if (Array.isArray(beforeValue)) {
|
||||
after[key] = beforeValue;
|
||||
} else if (typeof beforeValue === 'object') {
|
||||
} else if (afterValue && typeof beforeValue === 'object') {
|
||||
convertBackArray(beforeValue, afterValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1009,6 +1009,20 @@ describe('Bridge', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('Change options with null', async () => {
|
||||
zigbeeHerdsman.permitJoin.mockClear();
|
||||
expect(settings.get().serial).toStrictEqual({"disable_led": false, "port": "/dev/dummy"})
|
||||
MQTT.publish.mockClear();
|
||||
MQTT.events.message('zigbee2mqtt/bridge/request/options', stringify({"options":{"serial":{"disable_led":false,"port":null}}}));
|
||||
await flushPromises();
|
||||
expect(settings.get().serial).toStrictEqual({"disable_led": false, "port": null});
|
||||
expect(MQTT.publish).toHaveBeenCalledWith(
|
||||
'zigbee2mqtt/bridge/response/options',
|
||||
stringify({"data":{"restart_required":true},"status":"ok"}),
|
||||
{retain: false, qos: 0}, expect.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it('Change options invalid payload', async () => {
|
||||
zigbeeHerdsman.permitJoin.mockClear();
|
||||
MQTT.publish.mockClear();
|
||||
|
||||
Reference in New Issue
Block a user