mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 00:38:28 +00:00
test(hooks): dedupe unsupported npm spec assertion
This commit is contained in:
@@ -60,6 +60,17 @@ function writeArchiveFixture(params: { fileName: string; contents: Buffer }) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function expectUnsupportedNpmSpec(
|
||||||
|
install: (spec: string) => Promise<{ ok: boolean; error?: string }>,
|
||||||
|
) {
|
||||||
|
const result = await install("github:evil/evil");
|
||||||
|
expect(result.ok).toBe(false);
|
||||||
|
if (result.ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
expect(result.error).toContain("unsupported npm spec");
|
||||||
|
}
|
||||||
|
|
||||||
describe("installHooksFromArchive", () => {
|
describe("installHooksFromArchive", () => {
|
||||||
it.each([
|
it.each([
|
||||||
{
|
{
|
||||||
@@ -365,12 +376,7 @@ describe("installHooksFromNpmSpec", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("rejects non-registry npm specs", async () => {
|
it("rejects non-registry npm specs", async () => {
|
||||||
const result = await installHooksFromNpmSpec({ spec: "github:evil/evil" });
|
await expectUnsupportedNpmSpec((spec) => installHooksFromNpmSpec({ spec }));
|
||||||
expect(result.ok).toBe(false);
|
|
||||||
if (result.ok) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
expect(result.error).toContain("unsupported npm spec");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("aborts when integrity drift callback rejects the fetched artifact", async () => {
|
it("aborts when integrity drift callback rejects the fetched artifact", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user