From bfd360b099bf40fe46ecbcceacffeab47350bdd1 Mon Sep 17 00:00:00 2001 From: Dominic Griesel Date: Tue, 31 Oct 2023 15:49:27 +0100 Subject: [PATCH] test: include all 3 possible cases --- .../test/compat/treatBasicSetAsEvent.test.ts | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/packages/zwave-js/src/lib/test/compat/treatBasicSetAsEvent.test.ts b/packages/zwave-js/src/lib/test/compat/treatBasicSetAsEvent.test.ts index 6d0e1c4eb9b3..50de561b29fd 100644 --- a/packages/zwave-js/src/lib/test/compat/treatBasicSetAsEvent.test.ts +++ b/packages/zwave-js/src/lib/test/compat/treatBasicSetAsEvent.test.ts @@ -23,6 +23,65 @@ integrationTest( isControlled: true, version: 1, }, + ], + }, + + additionalDriverOptions: { + storage: { + deviceConfigPriorityDir: path.join( + __dirname, + "fixtures/basicEventNoSupport", + ), + }, + }, + + async testBody(t, driver, node, mockController, mockNode) { + // Make sure the custom config is loaded + const treatBasicSetAsEvent = node.deviceConfig?.compat + ?.treatBasicSetAsEvent; + t.is(treatBasicSetAsEvent, true); + + const valueIDs = node.getDefinedValueIDs(); + t.false( + valueIDs.some((v) => BasicCCValues.currentValue.is(v)), + "Found Basic CC currentValue although it shouldn't be exposed", + ); + t.false( + valueIDs.some((v) => BasicCCValues.targetValue.is(v)), + "Found Basic CC targetValue although it shouldn't be exposed", + ); + t.false( + valueIDs.some((v) => BasicCCValues.duration.is(v)), + "Found Basic CC duration although it shouldn't be exposed", + ); + t.false( + valueIDs.some((v) => BasicCCValues.restorePrevious.is(v)), + "Found Basic CC restorePrevious although it shouldn't be exposed", + ); + + t.true( + valueIDs.some((v) => BasicCCValues.compatEvent.is(v)), + "Did not find Basic CC compatEvent although it should be exposed", + ); + }, + }, +); + +integrationTest( + "Basic CC values should only include the compatEvent value if Basic CC should be hidden in favor of another CC, but the compat flag is set", + { + // debug: true, + + nodeCapabilities: { + manufacturerId: 0xdead, + productType: 0xbeef, + productId: 0xcafe, + + commandClasses: [ + CommandClasses.Version, + CommandClasses["Manufacturer Specific"], + // Basic CC is supported, but should be hidden + CommandClasses.Basic, CommandClasses["Binary Switch"], ], },