mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-10-23 14:22:38 +00:00
Add install code support (#13780)
* Add install code support * Update bridge.ts Co-authored-by: John Doe <nurikk@users.noreply.github.com>
This commit is contained in:
1 parent
0b645a4e6a
commit
9519ffdac7
4 files changed
+58
No files matched your search
@@ -913,6 +913,47 @@ describe('Bridge', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('Add install code', async () => {
|
||||
MQTT.publish.mockClear();
|
||||
|
||||
// By object
|
||||
zigbeeHerdsman.addInstallCode.mockClear();
|
||||
MQTT.events.message('zigbee2mqtt/bridge/request/install_code/add', stringify({value: 'my-code'}));
|
||||
await flushPromises();
|
||||
expect(zigbeeHerdsman.addInstallCode).toHaveBeenCalledTimes(1);
|
||||
expect(zigbeeHerdsman.addInstallCode).toHaveBeenCalledWith('my-code');
|
||||
expect(MQTT.publish).toHaveBeenCalledWith(
|
||||
'zigbee2mqtt/bridge/response/install_code/add',
|
||||
stringify({"data":{"value":'my-code'},"status":"ok"}),
|
||||
{retain: false, qos: 0}, expect.any(Function)
|
||||
);
|
||||
|
||||
// By string
|
||||
zigbeeHerdsman.addInstallCode.mockClear();
|
||||
MQTT.events.message('zigbee2mqtt/bridge/request/install_code/add', 'my-string-code');
|
||||
await flushPromises();
|
||||
expect(zigbeeHerdsman.addInstallCode).toHaveBeenCalledTimes(1);
|
||||
expect(zigbeeHerdsman.addInstallCode).toHaveBeenCalledWith('my-string-code');
|
||||
expect(MQTT.publish).toHaveBeenCalledWith(
|
||||
'zigbee2mqtt/bridge/response/install_code/add',
|
||||
stringify({"data":{"value":'my-code'},"status":"ok"}),
|
||||
{retain: false, qos: 0}, expect.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it('Add install code error', async () => {
|
||||
MQTT.publish.mockClear();
|
||||
zigbeeHerdsman.addInstallCode.mockClear();
|
||||
MQTT.events.message('zigbee2mqtt/bridge/request/install_code/add', stringify({wrong: 'my-code'}));
|
||||
await flushPromises();
|
||||
expect(zigbeeHerdsman.addInstallCode).toHaveBeenCalledTimes(0);
|
||||
expect(MQTT.publish).toHaveBeenCalledWith(
|
||||
'zigbee2mqtt/bridge/response/install_code/add',
|
||||
stringify({"data":{},"status":"error","error":"Invalid payload"}),
|
||||
{retain: false, qos: 0}, expect.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
it('Should allow to touchlink identify specific device', async () => {
|
||||
MQTT.publish.mockClear();
|
||||
zigbeeHerdsman.touchlinkIdentify.mockClear();
|
||||
|
||||
@@ -214,6 +214,7 @@ const mock = {
|
||||
backup: jest.fn(),
|
||||
isStopping: jest.fn(),
|
||||
permitJoin: jest.fn(),
|
||||
addInstallCode: jest.fn(),
|
||||
getCoordinatorVersion: jest.fn().mockReturnValue({type: 'z-Stack', meta: {version: 1, revision: 20190425}}),
|
||||
getNetworkParameters: jest.fn().mockReturnValue({panID: 0x162a, extendedPanID: [0, 11, 22], channel: 15}),
|
||||
on: (type, handler) => {
|
||||
|
||||
Reference in new issue
Block a user