mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-26 17:32:16 +00:00
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { tryHandleRootHelpFastPath } from "./entry.js";
|
|
|
|
describe("entry root help fast path", () => {
|
|
it("renders root help without importing the full program", () => {
|
|
const outputRootHelpMock = vi.fn();
|
|
|
|
const handled = tryHandleRootHelpFastPath(["node", "openclaw", "--help"], {
|
|
outputRootHelp: outputRootHelpMock,
|
|
env: {},
|
|
});
|
|
|
|
expect(handled).toBe(true);
|
|
expect(outputRootHelpMock).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("ignores non-root help invocations", () => {
|
|
const outputRootHelpMock = vi.fn();
|
|
|
|
const handled = tryHandleRootHelpFastPath(["node", "openclaw", "status", "--help"], {
|
|
outputRootHelp: outputRootHelpMock,
|
|
env: {},
|
|
});
|
|
|
|
expect(handled).toBe(false);
|
|
expect(outputRootHelpMock).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("skips the host help fast path when a container target is active", () => {
|
|
const outputRootHelpMock = vi.fn();
|
|
|
|
const handled = tryHandleRootHelpFastPath(
|
|
["node", "openclaw", "--container", "demo", "--help"],
|
|
{
|
|
outputRootHelp: outputRootHelpMock,
|
|
env: {},
|
|
},
|
|
);
|
|
|
|
expect(handled).toBe(false);
|
|
expect(outputRootHelpMock).not.toHaveBeenCalled();
|
|
});
|
|
});
|