Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Oct 24, 2024
1 parent 943a65c commit 12e4218
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 47 deletions.
9 changes: 6 additions & 3 deletions packages/zwave-js/src/lib/driver/Transaction.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { NoOperationCC } from "@zwave-js/cc/NoOperationCC";
import { MessagePriority } from "@zwave-js/core";
import { type Message, getDefaultPriority } from "@zwave-js/serial";
import { GetControllerVersionRequest } from "@zwave-js/serial/serialapi";
import { RemoveFailedNodeRequest } from "@zwave-js/serial/serialapi";
import { SendDataRequest } from "@zwave-js/serial/serialapi";
import test from "ava";
import type { ZWaveNode } from "../node/Node";
import { NodeStatus } from "../node/_Types";
import { GetControllerVersionRequest } from "../serialapi/capability/GetControllerVersionMessages";
import { RemoveFailedNodeRequest } from "../serialapi/network-mgmt/RemoveFailedNodeMessages";
import { SendDataRequest } from "../serialapi/transport/SendDataMessages";
import type { Driver } from "./Driver";
import {
type MessageGenerator,
Expand All @@ -23,6 +23,9 @@ function createDummyMessageGenerator(msg: Message): MessageGenerator {
self: undefined,
current: undefined,
parent: undefined as any,
reset() {
this.current = undefined;
},
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/zwave-js/src/lib/test/cc/CommandClass.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
implementedVersion,
} from "@zwave-js/cc";
import { CommandClasses } from "@zwave-js/core";
import { SendDataRequest } from "@zwave-js/serial/serialapi";
import test from "ava";
import { SendDataRequest } from "../../serialapi/transport/SendDataMessages";

@implementedVersion(7)
@commandClass(0xffff as any)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { WakeUpTime, ZWaveProtocolCCAssignSUCReturnRoute } from "@zwave-js/cc";
import { TransmitStatus, ZWaveDataRate } from "@zwave-js/core";
import { FunctionType } from "@zwave-js/serial";
import {
AssignSUCReturnRouteRequest,
AssignSUCReturnRouteResponse,
} from "@zwave-js/serial/serialapi";
import {
DeleteSUCReturnRouteRequest,
DeleteSUCReturnRouteRequestTransmitReport,
DeleteSUCReturnRouteResponse,
} from "@zwave-js/serial/serialapi";
import {
type MockControllerBehavior,
createMockZWaveRequestFrame,
Expand All @@ -10,15 +19,6 @@ import {
MockControllerCommunicationState,
MockControllerStateKeys,
} from "../../controller/MockControllerState";
import {
AssignSUCReturnRouteRequest,
AssignSUCReturnRouteResponse,
} from "../../serialapi/network-mgmt/AssignSUCReturnRouteMessages";
import {
DeleteSUCReturnRouteRequest,
DeleteSUCReturnRouteRequestTransmitReport,
DeleteSUCReturnRouteResponse,
} from "../../serialapi/network-mgmt/DeleteSUCReturnRouteMessages";
import { integrationTest } from "../integrationTestSuite";

// Repro for https://github.com/zwave-js/node-zwave-js/issues/6363
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { MultiCommandCCCommandEncapsulation } from "@zwave-js/cc/MultiCommandCC"
import { SecurityCCCommandEncapsulation } from "@zwave-js/cc/SecurityCC";
import { AssociationCommand } from "@zwave-js/cc/safe";
import { CommandClasses, ZWaveError, ZWaveErrorCodes } from "@zwave-js/core";
import { ApplicationCommandRequest } from "@zwave-js/serial/serialapi";
import { MockController, MockNode } from "@zwave-js/testing";
import ava, { type TestFn } from "ava";
import { createDefaultMockControllerBehaviors } from "../../../Utils";
import type { Driver } from "../../driver/Driver";
import { createAndStartTestingDriver } from "../../driver/DriverMock";
import { ApplicationCommandRequest } from "../../serialapi/application/ApplicationCommandRequest";

interface TestContext {
driver: Driver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { FirmwareUpdateMetaDataCC } from "@zwave-js/cc/FirmwareUpdateMetaDataCC"
import { MultiChannelCCCommandEncapsulation } from "@zwave-js/cc/MultiChannelCC";
import { SecurityCCCommandEncapsulation } from "@zwave-js/cc/SecurityCC";
import { EncapsulationFlags, TransmitOptions } from "@zwave-js/core";
import { SendDataRequest } from "@zwave-js/serial/serialapi";
import { MockController } from "@zwave-js/testing";
import ava, { type TestFn } from "ava";
import { createDefaultMockControllerBehaviors } from "../../../Utils";
import type { Driver } from "../../driver/Driver";
import { createAndStartTestingDriver } from "../../driver/DriverMock";
import { SendDataRequest } from "../../serialapi/transport/SendDataMessages";

interface TestContext {
driver: Driver;
Expand Down Expand Up @@ -46,13 +46,11 @@ test("should compute the correct net payload sizes", (t) => {
const testMsg1 = new SendDataRequest({
command: new SecurityCCCommandEncapsulation({
nodeId: 2,
ownNodeId: driver.ownNodeId,
securityManager: driver.securityManager!,
encapsulated: {} as any,
}),
transmitOptions: TransmitOptions.DEFAULT,
});
testMsg1.command.encapsulated = undefined as any;
testMsg1.command!.encapsulated = undefined as any;
t.is(driver.computeNetCCPayloadSize(testMsg1), 26);

const multiChannelCC = new MultiChannelCCCommandEncapsulation({
Expand All @@ -63,8 +61,6 @@ test("should compute the correct net payload sizes", (t) => {
const testMsg2 = new SendDataRequest({
command: new SecurityCCCommandEncapsulation({
nodeId: 2,
ownNodeId: driver.ownNodeId,
securityManager: driver.securityManager!,
encapsulated: multiChannelCC,
}),
transmitOptions: TransmitOptions.NoRoute,
Expand Down
14 changes: 7 additions & 7 deletions packages/zwave-js/src/lib/test/driver/controllerJammed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import {
getZWaveChipType,
} from "@zwave-js/core";
import { FunctionType } from "@zwave-js/serial";
import { SoftResetRequest } from "@zwave-js/serial/serialapi";
import {
SendDataAbort,
SendDataRequest,
SendDataRequestTransmitReport,
SendDataResponse,
} from "@zwave-js/serial/serialapi";
import { type MockControllerBehavior } from "@zwave-js/testing";
import { wait } from "alcalzone-shared/async";
import sinon from "sinon";
import {
MockControllerCommunicationState,
MockControllerStateKeys,
} from "../../controller/MockControllerState";
import { SoftResetRequest } from "../../serialapi/misc/SoftResetRequest";
import {
SendDataAbort,
SendDataRequest,
SendDataRequestTransmitReport,
SendDataResponse,
} from "../../serialapi/transport/SendDataMessages";
import { integrationTest } from "../integrationTestSuite";
import { integrationTest as integrationTestMulti } from "../integrationTestSuiteMulti";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { BasicCCGet, BasicCCSet } from "@zwave-js/cc";
import { MessagePriority, NodeStatus } from "@zwave-js/core";
import { type SendDataRequest } from "@zwave-js/serial/serialapi";
import { MOCK_FRAME_ACK_TIMEOUT, MockZWaveFrameType } from "@zwave-js/testing";
import { wait } from "alcalzone-shared/async";
import path from "node:path";
import { type SendDataRequest } from "../../serialapi/transport/SendDataMessages";
import { integrationTest } from "../integrationTestSuite";

// Repro from #1078
Expand Down
6 changes: 4 additions & 2 deletions packages/zwave-js/src/lib/test/driver/receiveMessages.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { WakeUpCCIntervalSet } from "@zwave-js/cc/WakeUpCC";
import { ApplicationCommandRequest } from "@zwave-js/serial/serialapi";
import { MockController } from "@zwave-js/testing";
import ava, { type TestFn } from "ava";
import type { Driver } from "../../driver/Driver";
import { createAndStartTestingDriver } from "../../driver/DriverMock";
import { ApplicationCommandRequest } from "../../serialapi/application/ApplicationCommandRequest";

interface TestContext {
driver: Driver;
Expand Down Expand Up @@ -43,7 +43,9 @@ test.serial(
wakeUpInterval: 5,
}),
});
controller.serial.emitData(req.serialize(driver));
controller.serial.emitData(
req.serialize(driver["getEncodingContext"]()),
);
await controller.expectHostACK(1000);
t.pass();
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SecurityCCNonceGet } from "@zwave-js/cc";
import { CommandClasses } from "@zwave-js/core";
import { SendDataRequest } from "@zwave-js/serial/serialapi";
import path from "node:path";
import { SendDataRequest } from "../../serialapi/transport/SendDataMessages";
import { integrationTest } from "../integrationTestSuite";

integrationTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {
} from "../../controller/MockControllerState";

import { TransmitStatus } from "@zwave-js/core";
import { SoftResetRequest } from "../../serialapi/misc/SoftResetRequest";
import { SoftResetRequest } from "@zwave-js/serial/serialapi";

import {
SendDataAbort,
SendDataRequest,
SendDataRequestTransmitReport,
SendDataResponse,
} from "../../serialapi/transport/SendDataMessages";
} from "@zwave-js/serial/serialapi";
import { integrationTest } from "../integrationTestSuite";

let shouldTimeOut: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ import {
ZWaveErrorCodes,
assertZWaveError,
} from "@zwave-js/core";
import path from "node:path";
import Sinon from "sinon";
import { determineNIF } from "../../controller/NodeInformationFrame";
import {
SerialAPIStartedRequest,
SerialAPIWakeUpReason,
} from "../../serialapi/application/SerialAPIStartedRequest";
import { SoftResetRequest } from "../../serialapi/misc/SoftResetRequest";
} from "@zwave-js/serial/serialapi";
import { SoftResetRequest } from "@zwave-js/serial/serialapi";
import {
RequestNodeInfoRequest,
RequestNodeInfoResponse,
} from "../../serialapi/network-mgmt/RequestNodeInfoMessages";
} from "@zwave-js/serial/serialapi";
import {
SendDataAbort,
SendDataRequest,
SendDataResponse,
} from "../../serialapi/transport/SendDataMessages";
} from "@zwave-js/serial/serialapi";
import path from "node:path";
import Sinon from "sinon";
import { determineNIF } from "../../controller/NodeInformationFrame";
import { integrationTest } from "../integrationTestSuite";
import { integrationTest as integrationTestMulti } from "../integrationTestSuiteMulti";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
SendDataAbort,
SendDataRequest,
SendDataRequestTransmitReport,
} from "../../serialapi/transport/SendDataMessages";
} from "@zwave-js/serial/serialapi";
import { integrationTest } from "../integrationTestSuite";

let shouldTimeOut: boolean;
Expand Down
10 changes: 5 additions & 5 deletions packages/zwave-js/src/lib/test/driver/unresponsiveStick.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ZWaveErrorCodes, assertZWaveError } from "@zwave-js/core";
import { FunctionType } from "@zwave-js/serial";
import { type MockControllerBehavior } from "@zwave-js/testing";
import { wait } from "alcalzone-shared/async";
import Sinon from "sinon";
import {
GetControllerIdRequest,
type GetControllerIdResponse,
} from "../../serialapi/memory/GetControllerIdMessages";
import { SoftResetRequest } from "../../serialapi/misc/SoftResetRequest";
} from "@zwave-js/serial/serialapi";
import { SoftResetRequest } from "@zwave-js/serial/serialapi";
import { type MockControllerBehavior } from "@zwave-js/testing";
import { wait } from "alcalzone-shared/async";
import Sinon from "sinon";
import { integrationTest } from "../integrationTestSuite";

let shouldRespond = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
MultilevelSwitchCCSet,
} from "@zwave-js/cc";
import { CommandClasses } from "@zwave-js/core";
import { ApplicationUpdateRequestNodeInfoReceived } from "@zwave-js/serial/serialapi";
import { type MockNodeBehavior, MockZWaveFrameType } from "@zwave-js/testing";
import { wait } from "alcalzone-shared/async";
import { ApplicationUpdateRequestNodeInfoReceived } from "../../serialapi/application/ApplicationUpdateRequest";
import { integrationTest } from "../integrationTestSuite";

integrationTest(
Expand Down

0 comments on commit 12e4218

Please sign in to comment.