Skip to content

Commit

Permalink
test: fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Dec 5, 2024
1 parent 544fb34 commit a4a6240
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/zwave-js/src/lib/test/driver/unresponsiveStick.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
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 { vi } from "vitest";
import { integrationTest } from "../integrationTestSuite.js";

let shouldRespond = true;
Expand Down Expand Up @@ -85,11 +85,13 @@ integrationTest(
shouldRespond = false;
mockController.autoAckHostMessages = false;

const serialPortCloseSpy = Sinon.stub().callsFake(() => {
shouldRespond = true;
mockController.autoAckHostMessages = true;
});
mockController.serial.on("close", serialPortCloseSpy);
const serialPortCloseSpy = vi.spyOn(mockController.serial, "close")
.mockImplementation(
async () => {
shouldRespond = true;
mockController.autoAckHostMessages = true;
},
);

await wait(1000);

Expand All @@ -108,7 +110,7 @@ integrationTest(

// The serial port should have been closed and reopened
await wait(100);
t.expect(serialPortCloseSpy.called).toBe(true);
t.expect(serialPortCloseSpy).toHaveBeenCalled();

// FIXME: When closing the serial port, we lose the connection between the mock port instance and the controller
// Fix it at some point, then enable the below test.
Expand Down

0 comments on commit a4a6240

Please sign in to comment.