mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 05:27:39 +00:00
fix(imessage): prevent rpc spawn in tests
This commit is contained in:
22
src/imessage/client.test.ts
Normal file
22
src/imessage/client.test.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const spawnMock = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("node:child_process", () => ({
|
||||
spawn: (...args: unknown[]) => spawnMock(...args),
|
||||
}));
|
||||
|
||||
describe("createIMessageRpcClient", () => {
|
||||
beforeEach(() => {
|
||||
spawnMock.mockReset();
|
||||
vi.stubEnv("VITEST", "true");
|
||||
});
|
||||
|
||||
it("refuses to spawn imsg rpc in test environments", async () => {
|
||||
const { createIMessageRpcClient } = await import("./client.js");
|
||||
await expect(createIMessageRpcClient()).rejects.toThrow(
|
||||
/Refusing to start imsg rpc in test environment/i,
|
||||
);
|
||||
expect(spawnMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user