Files
openclaw/src/cli/update-cli.test-helpers.test.ts
2026-04-04 16:55:04 +09:00

22 lines
801 B
TypeScript

import path from "node:path";
import { describe, expect, it } from "vitest";
import { isOwningNpmCommand } from "./update-cli.test-helpers.js";
describe("isOwningNpmCommand", () => {
it("accepts absolute npm binaries under the owning prefix", () => {
const prefix = path.join(path.sep, "opt", "homebrew");
expect(isOwningNpmCommand(path.join(prefix, "bin", "npm"), prefix)).toBe(true);
expect(isOwningNpmCommand(path.join(prefix, "npm.cmd"), prefix)).toBe(true);
});
it("rejects plain npm and paths outside the owning prefix", () => {
const prefix = path.join(path.sep, "opt", "homebrew");
expect(isOwningNpmCommand("npm", prefix)).toBe(false);
expect(isOwningNpmCommand(path.join(path.sep, "usr", "local", "bin", "npm"), prefix)).toBe(
false,
);
});
});