Update externalModules_spec to handle variable npm args length

This commit is contained in:
Nick O'Leary 2021-04-29 11:04:19 +01:00
parent 676f790933
commit 00caa13a12
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 4 additions and 3 deletions

View File

@ -48,13 +48,14 @@ describe("externalModules api", function() {
beforeEach(function() {
sinon.stub(exec,"run").callsFake(async function(cmd, args, options) {
let error;
if (args[2] === "moduleNotFound") {
let moduleName = args[args.length-1];
if (moduleName === "moduleNotFound") {
error = new Error();
error.stderr = "E404";
} else if (args[2] === "moduleVersionNotFound") {
} else if (moduleName === "moduleVersionNotFound") {
error = new Error();
error.stderr = "ETARGET";
} else if (args[2] === "moduleFail") {
} else if (moduleName === "moduleFail") {
error = new Error();
error.stderr = "Some unexpected install error";
}