Skip to content

Commit 8e0c5c6

Browse files
committed
Tests fix
1 parent 1cf0896 commit 8e0c5c6

File tree

12 files changed

+89
-71
lines changed

12 files changed

+89
-71
lines changed

package-lock.json

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/unit/commands/app/create.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,18 @@ import shelljs from "shelljs";
77
import { join } from "path";
88
import sinon from "sinon";
99
import { runCommand } from "@oclif/test";
10-
import { cliux, configHandler } from "@contentstack/cli-utilities";
10+
import { cliux } from "@contentstack/cli-utilities";
1111
import messages from "../../../../src/messages";
1212
import config from "../../../../src/config";
1313
import * as mock from "../../mock/common.mock.json";
1414
import manifestData from "../../../../src/config/manifest.json";
1515
import orgManifestData from "../../../unit/config/org_manifest.json";
1616
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
1717
import axios from "axios";
18-
import { stubAuthentication } from "../../helpers/auth-stub-helper";
18+
import { stubAuthentication, MOCK_CMA } from "../../helpers/auth-stub-helper";
1919

2020
const { origin, pathname } = new URL(config.appBoilerplateGithubUrl);
2121
const zipPath = join(process.cwd(), "test", "unit", "mock", "boilerplate.zip");
22-
const region: { cma: string; name: string; cda: string } =
23-
configHandler.get("region");
2422
const developerHubBaseUrl = getDeveloperHubUrl();
2523

2624
class MockWriteStream extends PassThrough implements fs.WriteStream {
@@ -49,7 +47,7 @@ describe("app:create", () => {
4947
removeCallback: sandbox.stub(),
5048
}));
5149
nock(origin).get(pathname).reply(200, { data: "test-data" });
52-
nock(region.cma)
50+
nock(MOCK_CMA)
5351
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
5452
.reply(200, { organizations: mock.organizations });
5553
});
@@ -434,7 +432,7 @@ describe("app:create", () => {
434432

435433
describe("App creation with organization UID instead of app UID", () => {
436434
beforeEach(() => {
437-
nock(region.cma)
435+
nock(MOCK_CMA)
438436
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
439437
.reply(200, { organizations: mock.organizations });
440438

test/unit/commands/app/delete.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { expect } from "chai";
22
import { runCommand } from "@oclif/test";
3-
import { cliux, configHandler } from "@contentstack/cli-utilities";
3+
import { cliux } from "@contentstack/cli-utilities";
44
import sinon from "sinon";
55
import * as mock from "../../mock/common.mock.json";
66
import messages, { $t } from "../../../../src/messages";
77
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
88
import nock from "nock";
9-
import { stubAuthentication } from "../../helpers/auth-stub-helper";
9+
import { stubAuthentication, MOCK_CMA } from "../../helpers/auth-stub-helper";
1010

11-
const region: { cma: string; name: string; cda: string } =
12-
configHandler.get("region");
1311
const developerHubBaseUrl = getDeveloperHubUrl();
1412

1513
describe("app:delete", () => {
@@ -20,7 +18,7 @@ describe("app:delete", () => {
2018
// Stub authentication using shared helper
2119
stubAuthentication(sandbox);
2220

23-
nock(region.cma)
21+
nock(MOCK_CMA)
2422
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
2523
.reply(200, { organizations: mock.organizations });
2624
});

test/unit/commands/app/deploy.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { expect } from "chai";
22
import nock from "nock";
33
import { runCommand } from "@oclif/test";
4-
import { cliux, configHandler } from "@contentstack/cli-utilities";
4+
import { cliux } from "@contentstack/cli-utilities";
55
import messages, { $t } from "../../../../src/messages";
66
import * as mock from "../../mock/common.mock.json";
77
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
88
import sinon from "sinon";
9-
import { stubAuthentication } from "../../helpers/auth-stub-helper";
9+
import { stubAuthentication, MOCK_CMA } from "../../helpers/auth-stub-helper";
1010

11-
const region = configHandler.get("region");
1211
const developerHubBaseUrl = getDeveloperHubUrl();
1312

1413
describe("app:deploy", () => {
@@ -76,7 +75,7 @@ describe("app:deploy", () => {
7675
// Stub Launch.run
7776
sandbox.stub(require("@contentstack/cli-launch").Launch, "run").resolves();
7877

79-
nock(region.cma)
78+
nock(MOCK_CMA)
8079
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
8180
.reply(200, { organizations: mock.organizations });
8281

@@ -173,7 +172,7 @@ describe("app:deploy", () => {
173172
.stub(require("../../../../src/util/common-utils"), "updateApp")
174173
.resolves();
175174

176-
nock(region.cma)
175+
nock(MOCK_CMA)
177176
.get(
178177
"/v3/organizations?limit=100&asc=name&asc=name&include_count=true&skip=0"
179178
)
@@ -233,7 +232,7 @@ describe("app:deploy", () => {
233232
.stub(require("@contentstack/cli-launch").Launch, "run")
234233
.resolves();
235234

236-
nock(region.cma)
235+
nock(MOCK_CMA)
237236
.get(
238237
"/v3/organizations?limit=100&asc=name&asc=name&include_count=true&skip=0"
239238
)

test/unit/commands/app/get.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ import fs from "fs";
44
import { join } from "path";
55
import sinon from "sinon";
66
import { runCommand } from "@oclif/test";
7-
import { cliux, configHandler } from "@contentstack/cli-utilities";
7+
import { cliux } from "@contentstack/cli-utilities";
88
import messages, { $t } from "../../../../src/messages";
99
import * as commonUtils from "../../../../src/util/common-utils";
1010
import * as mock from "../../mock/common.mock.json";
1111
import manifestData from "../../../../src/config/manifest.json";
1212
import { getDeveloperHubUrl } from "../../../../src/util/inquirer";
1313
import config from "../../../../src/config";
14-
import { stubAuthentication } from "../../helpers/auth-stub-helper";
14+
import { stubAuthentication, MOCK_CMA } from "../../helpers/auth-stub-helper";
1515

16-
const region = configHandler.get("region");
1716
const developerHubBaseUrl = getDeveloperHubUrl();
1817

1918
describe("app:get", () => {
@@ -46,7 +45,7 @@ describe("app:get", () => {
4645
return cases[prompt.name];
4746
});
4847

49-
nock(region.cma)
48+
nock(MOCK_CMA)
5049
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
5150
.reply(200, { organizations: mock.organizations });
5251

@@ -81,7 +80,7 @@ describe("app:get", () => {
8180
sandbox.stub(fs, "readdirSync").returns([]);
8281
sandbox.stub(cliux, "inquire").resolves("test org 1");
8382

84-
nock(region.cma)
83+
nock(MOCK_CMA)
8584
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
8685
.reply(200, { organizations: mock.organizations });
8786

@@ -121,7 +120,7 @@ describe("app:get", () => {
121120
sandbox.stub(cliux, "confirm").resolves(false);
122121
sandbox.stub(cliux, "inquire").resolves("test org 1");
123122

124-
nock(region.cma)
123+
nock(MOCK_CMA)
125124
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
126125
.reply(200, { organizations: mock.organizations });
127126

@@ -160,7 +159,7 @@ describe("app:get", () => {
160159
sandbox.stub(cliux, "confirm").resolves(true);
161160
sandbox.stub(cliux, "inquire").resolves("test org 1");
162161

163-
nock(region.cma)
162+
nock(MOCK_CMA)
164163
.get("/v3/organizations?limit=100&asc=name&include_count=true&skip=0")
165164
.reply(200, { organizations: mock.organizations });
166165

0 commit comments

Comments
 (0)