Skip to content

Commit 37b8b7c

Browse files
committed
Fixed deploy test cases
1 parent c0837c2 commit 37b8b7c

1 file changed

Lines changed: 7 additions & 28 deletions

File tree

packages/contentstack-apps-cli/test/unit/commands/app/deploy.test.ts

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,12 @@ import sinon from "sinon";
99
import { stubAuthentication } from "../../helpers/auth-stub-helper";
1010
import Deploy from "../../../../src/commands/app/deploy";
1111
import { BaseCommand } from "../../../../src/base-command";
12-
import { join } from "path";
12+
import * as libCommonUtils from "../../../../src/util/common-utils";
13+
import * as libInquirer from "../../../../src/util/inquirer";
1314

1415
const region = configHandler.get("region");
15-
// Commands run from lib/ (oclif.commands); stub the same classes/modules the running command uses
16-
let BaseCommandToStub: typeof BaseCommand;
17-
let LibDeploy: typeof Deploy;
18-
let libCommonUtils: any;
19-
let libInquirer: any;
20-
try {
21-
BaseCommandToStub = require(join(process.cwd(), "lib", "base-command")).BaseCommand;
22-
} catch {
23-
BaseCommandToStub = BaseCommand;
24-
}
25-
try {
26-
LibDeploy = require(join(process.cwd(), "lib", "commands", "app", "deploy")).default;
27-
} catch {
28-
LibDeploy = Deploy;
29-
}
30-
try {
31-
libCommonUtils = require(join(process.cwd(), "lib", "util", "common-utils"));
32-
} catch {
33-
libCommonUtils = require("../../../../src/util/common-utils");
34-
}
35-
try {
36-
libInquirer = require(join(process.cwd(), "lib", "util", "inquirer"));
37-
} catch {
38-
libInquirer = require("../../../../src/util/inquirer");
39-
}
16+
const BaseCommandToStub = BaseCommand;
17+
const LibDeploy = Deploy;
4018
const developerHubBaseUrl = getDeveloperHubUrl();
4119

4220
describe("app:deploy", () => {
@@ -76,7 +54,7 @@ describe("app:deploy", () => {
7654
sandbox.stub(libInquirer, "getAppUrl").resolves("https://example.com");
7755
sandbox.stub(libInquirer, "askProjectType").resolves("existing");
7856
sandbox.stub(libInquirer, "askConfirmation").resolves(false);
79-
sandbox.stub(libInquirer, "selectProject").resolves(null);
57+
sandbox.stub(libInquirer, "selectProject").resolves(undefined);
8058
sandbox.stub(libInquirer, "askProjectName").resolves("test-project");
8159

8260
// Stub Launch.run
@@ -355,14 +333,15 @@ describe("app:deploy", () => {
355333
sandbox.stub(libInquirer, "askProjectType").resolves("new");
356334
sandbox.stub(libInquirer, "askProjectName").resolves("new-project");
357335
sandbox.stub(libInquirer, "askConfirmation").resolves(false);
358-
sandbox.stub(libInquirer, "selectProject").resolves(null);
336+
sandbox.stub(libInquirer, "selectProject").resolves(undefined);
359337

360338
sandbox.stub(libCommonUtils, "getProjects").resolves([
361339
{
362340
name: "new-project",
363341
uid: "project-2",
364342
url: "https://new-project.com",
365343
environmentUid: "env-2",
344+
developerHubAppUid: null,
366345
},
367346
]);
368347
sandbox.stub(libCommonUtils, "setupConfig").returns({

0 commit comments

Comments
 (0)