Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(verify): inject undefined instead of null for a local scan #418

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/commands/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ function separatorLine() {
return grey("-".repeat(80));
}

export async function main(packageName = null, options, verifyFn = verify) {
export async function main(
packageName = undefined,
options,
verifyFn = verify
) {
const payload = await verifyFn(packageName);

if (options.json) {
Expand Down
17 changes: 15 additions & 2 deletions test/commands/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,28 @@ const kExpectVerifyJson = `{
}`.split("\n");

test("should execute verify command", async() => {
const expectedValues = VERIFY_EXPECTED_LINES.slice(0);

for await (const line of runProcess({ path: path.join(kProcessDir, "verify.js") })) {
const expectedLine = VERIFY_EXPECTED_LINES.shift();
const expectedLine = expectedValues.shift();
assert.equal(line.trimEnd(), expectedLine, `should be ${expectedLine}`);
}
});

test("should execute verify command with json option", async() => {
const expectedValues = kExpectVerifyJson.slice(0);

for await (const line of runProcess({ path: path.join(kProcessDir, "verify-json.js") })) {
const expectedLine = kExpectVerifyJson.shift();
const expectedLine = expectedValues.shift();
assert.equal(line.trimEnd(), expectedLine, `should be ${expectedLine}`);
}
});

test("should execute verify command with undefined package name and json option", async() => {
const expectedValues = kExpectVerifyJson.slice(0);

for await (const line of runProcess({ path: path.join(kProcessDir, "verify-undefined.js") })) {
const expectedLine = expectedValues.shift();
assert.equal(line.trimEnd(), expectedLine, `should be ${expectedLine}`);
}
});
9 changes: 9 additions & 0 deletions test/process/verify-undefined.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Import Internal Dependencies
import * as verify from "../../src/commands/verify.js";
import { prepareProcess } from "../helpers/cliCommandRunner.js";

function mockVerify() {
return ({ foo: "bar" });
}

prepareProcess(verify.main, [undefined, { json: true }, mockVerify]);
Loading