mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 09:42:44 +00:00
refactor(test): share internal hook and npm pack assertions
This commit is contained in:
@@ -3,7 +3,10 @@ import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { expectSingleNpmInstallIgnoreScriptsCall } from "../test-utils/exec-assertions.js";
|
||||
import {
|
||||
expectSingleNpmInstallIgnoreScriptsCall,
|
||||
expectSingleNpmPackIgnoreScriptsCall,
|
||||
} from "../test-utils/exec-assertions.js";
|
||||
import { isAddressInUseError } from "./gmail-watcher.js";
|
||||
|
||||
const fixtureRoot = path.join(os.tmpdir(), `openclaw-hook-install-${randomUUID()}`);
|
||||
@@ -273,18 +276,10 @@ describe("installHooksFromNpmSpec", () => {
|
||||
expect(result.hookPackId).toBe("test-hooks");
|
||||
expect(fs.existsSync(path.join(result.targetDir, "hooks", "one-hook", "HOOK.md"))).toBe(true);
|
||||
|
||||
const packCalls = run.mock.calls.filter(
|
||||
(c) => Array.isArray(c[0]) && c[0][0] === "npm" && c[0][1] === "pack",
|
||||
);
|
||||
expect(packCalls.length).toBe(1);
|
||||
const packCall = packCalls[0];
|
||||
if (!packCall) {
|
||||
throw new Error("expected npm pack call");
|
||||
}
|
||||
const [argv, options] = packCall;
|
||||
expect(argv).toEqual(["npm", "pack", "@openclaw/test-hooks@0.0.1", "--ignore-scripts"]);
|
||||
const commandOptions = typeof options === "number" ? undefined : options;
|
||||
expect(commandOptions?.env).toMatchObject({ NPM_CONFIG_IGNORE_SCRIPTS: "true" });
|
||||
expectSingleNpmPackIgnoreScriptsCall({
|
||||
calls: run.mock.calls,
|
||||
expectedSpec: "@openclaw/test-hooks@0.0.1",
|
||||
});
|
||||
|
||||
expect(packTmpDir).not.toBe("");
|
||||
expect(fs.existsSync(packTmpDir)).toBe(false);
|
||||
|
||||
Reference in New Issue
Block a user