Skip to content

Commit

Permalink
refactor: move mock behaviors to improve tree shaking (#7487)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Dec 12, 2024
1 parent 3f6229b commit 9d5e3fa
Show file tree
Hide file tree
Showing 21 changed files with 22 additions and 22 deletions.
2 changes: 2 additions & 0 deletions packages/zwave-js/src/Testing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export { createDefaultBehaviors as createDefaultMockControllerBehaviors } from "./lib/controller/MockControllerBehaviors.js";
export { createAndStartDriverWithMockPort } from "./lib/driver/DriverMock.js";
export { createDefaultBehaviors as createDefaultMockNodeBehaviors } from "./lib/node/MockNodeBehaviors.js";
export { MockServer, createMockNodeOptionsFromDump } from "./mockServer.js";
export type {
MockServerControllerOptions,
Expand Down
2 changes: 0 additions & 2 deletions packages/zwave-js/src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export {
getEnumMemberName,
num2hex,
} from "@zwave-js/shared/safe";
export { createDefaultBehaviors as createDefaultMockControllerBehaviors } from "./lib/controller/MockControllerBehaviors.js";
export { driverPresets } from "./lib/driver/ZWaveOptions.js";
export {
formatLifelineHealthCheckRound,
Expand All @@ -33,4 +32,3 @@ export {
formatRouteHealthCheckSummary,
healthCheckRatingToWord,
} from "./lib/node/HealthCheck.js";
export { createDefaultBehaviors as createDefaultMockNodeBehaviors } from "./lib/node/MockNodeBehaviors.js";
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ZWaveErrorCodes, assertZWaveError } from "@zwave-js/core";
import type { ThrowingMap } from "@zwave-js/shared";
import { MockController } from "@zwave-js/testing";
import { test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../Testing.js";
import type { Driver } from "../driver/Driver.js";
import { createAndStartTestingDriver } from "../driver/DriverMock.js";
import { ZWaveNode } from "../node/Node.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/zwave-js/src/lib/node/Endpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@zwave-js/core";
import { MockController } from "@zwave-js/testing";
import { afterEach, test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../Testing.js";
import type { Driver } from "../driver/Driver.js";
import { createAndStartTestingDriver } from "../driver/DriverMock.js";
import { Endpoint } from "./Endpoint.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/zwave-js/src/lib/node/VirtualEndpoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { test as baseTest } from "vitest";
import {
createDefaultMockControllerBehaviors,
createDefaultMockNodeBehaviors,
} from "../../Utils.js";
} from "../../Testing.js";
import type { Driver } from "../driver/Driver.js";
import { createAndStartTestingDriver } from "../driver/DriverMock.js";
import { ZWaveNode } from "./Node.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/zwave-js/src/lib/test/cc/API.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NOT_KNOWN } from "@zwave-js/core";
import type { ThrowingMap } from "@zwave-js/shared";
import { MockController } from "@zwave-js/testing";
import { test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { ZWaveNode } from "../../node/Node.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ThrowingMap } from "@zwave-js/shared";
import { MockController } from "@zwave-js/testing";
import sinon from "sinon";
import { afterEach, beforeEach, test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { ZWaveNode } from "../../node/Node.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CommandClasses, ZWaveError, ZWaveErrorCodes } from "@zwave-js/core";
import { ApplicationCommandRequest } from "@zwave-js/serial/serialapi";
import { MockController, MockNode } from "@zwave-js/testing";
import { test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EncapsulationFlags, TransmitOptions } from "@zwave-js/core";
import { SendDataRequest } from "@zwave-js/serial/serialapi";
import { MockController } from "@zwave-js/testing";
import { test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CommandClasses, type ValueID } from "@zwave-js/core";
import { MockController } from "@zwave-js/testing";
import { test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { ZWaveNode } from "../../node/Node.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { fileURLToPath } from "node:url";
import {
createDefaultMockControllerBehaviors,
createDefaultMockNodeBehaviors,
} from "../../Utils.js";
} from "../../Testing.js";
import {
type CreateAndStartDriverWithMockPortResult,
createAndStartDriverWithMockPort,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CommandClasses } from "@zwave-js/core";
import { MockController } from "@zwave-js/testing";
import { test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { ZWaveNode } from "../../node/Node.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "@zwave-js/cc";
import { CommandClasses, ValueDB } from "@zwave-js/core";
import { MockController } from "@zwave-js/testing";
import { afterEach, test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { DeviceClass } from "../../node/DeviceClass.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import type { ThrowingMap } from "@zwave-js/shared";
import { MockController } from "@zwave-js/testing";
import { test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { ZWaveNode } from "../../node/Node.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import type { ThrowingMap } from "@zwave-js/shared";
import { MockController } from "@zwave-js/testing";
import { afterEach, beforeEach, test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { DeviceClass } from "../../node/DeviceClass.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ThrowingMap } from "@zwave-js/shared";
import { MockController } from "@zwave-js/testing";
import sinon from "sinon";
import { type TaskContext, test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { ZWaveNode } from "../../node/Node.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/zwave-js/src/lib/test/node/Node.status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NodeStatus } from "@zwave-js/core";
import { MockController } from "@zwave-js/testing";
import sinon from "sinon";
import { test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { ZWaveNode } from "../../node/Node.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CommandClasses, InterviewStage, NodeStatus } from "@zwave-js/core";
import type { ThrowingMap } from "@zwave-js/shared";
import { MockController } from "@zwave-js/testing";
import { afterEach, test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { ZWaveNode } from "../../node/Node.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ThrowingMap } from "@zwave-js/shared";
import { MockController } from "@zwave-js/testing";
import sinon from "sinon";
import { afterEach, beforeEach, test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { ZWaveNode } from "../../node/Node.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { ThrowingMap } from "@zwave-js/shared";
import { MockController } from "@zwave-js/testing";
import { wait } from "alcalzone-shared/async";
import { test as baseTest } from "vitest";
import { createDefaultMockControllerBehaviors } from "../../../Utils.js";
import { createDefaultMockControllerBehaviors } from "../../../Testing.js";
import type { Driver } from "../../driver/Driver.js";
import { createAndStartTestingDriver } from "../../driver/DriverMock.js";
import { ZWaveNode } from "../../node/Node.js";
Expand Down
4 changes: 2 additions & 2 deletions packages/zwave-js/src/mockServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ import {
import { createDeferredPromise } from "alcalzone-shared/deferred-promise";
import { type AddressInfo, type Server, createServer } from "node:net";
import {
ProtocolVersion,
createDefaultMockControllerBehaviors,
createDefaultMockNodeBehaviors,
} from "./Utils.js";
} from "./Testing.js";
import { ProtocolVersion } from "./Utils.js";
import { type CommandClassDump, type NodeDump } from "./lib/node/Dump.js";

export type MockServerControllerOptions =
Expand Down

0 comments on commit 9d5e3fa

Please sign in to comment.