Files
openclaw/test/scripts/check.test.ts
T
Peter Steinberger c70aee247e refactor(scripts): migrate JavaScript tools to TypeScript (#121005)
* refactor(scripts): migrate JavaScript tools to TypeScript

* fix(ci): keep changed-scope preflight zero-install

* fix(ci): preserve zero-install script owners

* fix(ci): complete script migration follow-through

* fix(release): keep stable closeout zero-install

* fix(scripts): preserve standalone execution boundaries

* fix(scripts): repair standalone loader boundaries

* fix(scripts): normalize gateway observation ids

* fix(scripts): keep Docker packager standalone

* test(scripts): preserve rebase cleanup helpers

* test(sessions): use tracked temp directory
2026-08-09 07:21:35 -07:00

50 lines
1.7 KiB
TypeScript

// Check tests cover check script behavior.
import { spawnSync } from "node:child_process";
import { describe, expect, it } from "vitest";
import { runCommand } from "../../scripts/check.mts";
describe("scripts/check", () => {
function runCheck(...args: string[]) {
return spawnSync(process.execPath, ["--import", "tsx", "scripts/check.mts", ...args], {
cwd: process.cwd(),
encoding: "utf8",
});
}
it("prints help without running check stages", () => {
const result = runCheck("--help");
expect(result.status).toBe(0);
expect(result.stderr).toBe("");
expect(result.stdout).toContain("Usage: node --import tsx scripts/check.mts");
expect(result.stdout).not.toContain("[check]");
});
it("rejects unknown args before running check stages", () => {
for (const args of [["--bogus"], ["bogus", "--help"]]) {
const result = runCheck(...args);
expect(result.status).toBe(2);
expect(result.stdout).toBe("");
expect(result.stderr).toContain(`unknown argument: ${args[0]}`);
expect(result.stderr).toContain("Usage: node --import tsx scripts/check.mts");
expect(result.stderr).not.toContain("[check]");
}
});
it("runs pnpm commands through the managed child runner", async () => {
const calls: Array<{ args: string[]; bin: string }> = [];
const result = await runCommand(
{ args: ["lint"], name: "lint" },
async (options: { args: string[]; bin: string }) => {
calls.push(options);
return 0;
},
);
expect(calls).toEqual([{ args: ["lint"], bin: "pnpm" }]);
expect(result).toMatchObject({ name: "lint", status: 0 });
expect(result.durationMs).toBeGreaterThanOrEqual(0);
});
});