mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Move safe-chain package to packages/safe-chain
This commit is contained in:
parent
fc9a9ca129
commit
7673d32912
68 changed files with 85 additions and 52 deletions
|
|
@ -0,0 +1,47 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { describe, it, mock } from "node:test";
|
||||
|
||||
describe("shouldScanCommand", async () => {
|
||||
const isSupportedCommandMock = mock.fn(() => undefined);
|
||||
|
||||
mock.module("../packagemanager/currentPackageManager.js", {
|
||||
namedExports: {
|
||||
getPackageManager: () => {
|
||||
return {
|
||||
isSupportedCommand: isSupportedCommandMock,
|
||||
getDependencyUpdatesForCommand: () => [],
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const { shouldScanCommand } = await import("./index.js");
|
||||
|
||||
it("should return false if the argument is an empty array", () => {
|
||||
const result = shouldScanCommand([]);
|
||||
|
||||
assert.strictEqual(result, false);
|
||||
});
|
||||
|
||||
it("should return false if the argument is undefined", () => {
|
||||
const result = shouldScanCommand(undefined);
|
||||
|
||||
assert.strictEqual(result, false);
|
||||
});
|
||||
|
||||
it("should return true if the package manager supports the command", () => {
|
||||
isSupportedCommandMock.mock.mockImplementation(() => true);
|
||||
|
||||
const result = shouldScanCommand(["install", "lodash"]);
|
||||
|
||||
assert.strictEqual(result, true);
|
||||
});
|
||||
|
||||
it("should return false if the package manager does not support the command", () => {
|
||||
isSupportedCommandMock.mock.mockImplementation(() => false);
|
||||
|
||||
const result = shouldScanCommand(["unknown", "command"]);
|
||||
|
||||
assert.strictEqual(result, false);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue