forked from openclaw/openclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser-node-host.test.ts
More file actions
35 lines (27 loc) · 1.23 KB
/
Copy pathbrowser-node-host.test.ts
File metadata and controls
35 lines (27 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { beforeEach, describe, expect, it, vi } from "vitest";
const loadActivatedBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
vi.mock("./facade-runtime.js", () => ({
loadActivatedBundledPluginPublicSurfaceModuleSync,
}));
describe("browser node-host facade", () => {
beforeEach(() => {
loadActivatedBundledPluginPublicSurfaceModuleSync.mockReset();
});
it("stays cold until the proxy command is called", async () => {
await import("./browser-node-host.js");
expect(loadActivatedBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();
});
it("delegates the proxy command through the activated runtime facade", async () => {
const runBrowserProxyCommand = vi.fn(async () => '{"ok":true}');
loadActivatedBundledPluginPublicSurfaceModuleSync.mockReturnValue({
runBrowserProxyCommand,
});
const facade = await import("./browser-node-host.js");
await expect(facade.runBrowserProxyCommand('{"path":"/"}')).resolves.toBe('{"ok":true}');
expect(loadActivatedBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledWith({
dirName: "browser",
artifactBasename: "runtime-api.js",
});
expect(runBrowserProxyCommand).toHaveBeenCalledWith('{"path":"/"}');
});
});