mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Initial commit
This commit is contained in:
parent
dd51a48435
commit
5eaf6ac3b3
51 changed files with 10087 additions and 1 deletions
47
src/scanning/index.shouldScanCommand.spec.js
Normal file
47
src/scanning/index.shouldScanCommand.spec.js
Normal file
|
|
@ -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