Files
oh-my-opencode/packages/omo-codex/plugin/components/lsp/test/codex-hook-cli.test.ts
T
2026-05-31 09:51:59 +09:00

29 lines
809 B
TypeScript

import { spawnSync } from "node:child_process";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
describe("codex PostToolUse hook CLI", () => {
it("#given malformed post-tool-use stdin #when hook CLI runs #then it no-ops without stderr", () => {
// given
const input = "break;\n";
// when
const result = runBuiltHookCli(input);
// then
expect(result.status).toBe(0);
expect(result.stderr).toBe("");
expect(result.stdout).toBe("");
});
});
function runBuiltHookCli(input: string): ReturnType<typeof spawnSync> {
const cliPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../dist/cli.js");
return spawnSync(process.execPath, [cliPath, "hook", "post-tool-use"], {
input,
encoding: "utf8",
});
}