Skip to content

Commit b150485

Browse files
author
Your Name
committed
fixed unit test cases
1 parent 7c17d34 commit b150485

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

packages/contentstack-import-setup/test/unit/import-config-handler.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from 'chai';
22
import * as path from 'path';
33
import * as os from 'os';
44
import * as fs from 'fs';
5-
import { stub, restore, SinonStub } from 'sinon';
5+
import { stub, restore, SinonStub, createSandbox } from 'sinon';
66
import * as utilities from '@contentstack/cli-utilities';
77
import * as cliAm from '@contentstack/cli-asset-management';
88
import setupConfig from '../../src/utils/import-config-handler';
@@ -153,11 +153,13 @@ describe('Import Config Handler', () => {
153153
});
154154

155155
it('should merge Asset Management export flags from detectAssetManagementExportFromContentDir into config', async () => {
156-
const detectStub = stub(cliAm, 'detectAssetManagementExportFromContentDir').returns({
156+
const sandbox = createSandbox();
157+
const detectFake = sandbox.fake.returns({
157158
assetManagementEnabled: true,
158159
source_stack: 'branch-source-key',
159160
assetManagementUrl: 'https://am.example.com',
160161
});
162+
sandbox.replaceGetter(cliAm, 'detectAssetManagementExportFromContentDir', () => detectFake);
161163

162164
try {
163165
const config = await setupConfig({
@@ -166,12 +168,12 @@ describe('Import Config Handler', () => {
166168
module: ['assets'],
167169
});
168170

169-
expect(detectStub.calledOnce).to.be.true;
170-
expect(config.assetManagementEnabled).to.equal(true);
171-
expect(config.assetManagementUrl).to.equal('https://am.example.com');
171+
expect(detectFake.calledOnce).to.be.true;
172+
expect(config.csAssetsEnabled).to.equal(true);
173+
expect(config.csAssetsUrl).to.equal('https://am.example.com');
172174
expect(config.source_stack).to.equal('branch-source-key');
173175
} finally {
174-
detectStub.restore();
176+
sandbox.restore();
175177
}
176178
});
177179
});

packages/contentstack-import-setup/test/unit/modules/assets.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ describe('AssetImportSetup Asset Management export', () => {
200200
backupDir,
201201
region: {
202202
cma: 'https://api.contentstack.io/v3',
203-
assetManagementUrl: 'https://am.example.com',
203+
csAssetsUrl: 'https://am.example.com',
204204
},
205205
host: 'https://api.contentstack.io/v3',
206206
fetchConcurrency: 2,
207207
writeConcurrency: 1,
208-
assetManagementEnabled: true,
208+
csAssetsEnabled: true,
209209
org_uid: 'org-uid-test',
210210
source_stack: 'source-api-key',
211211
context: {},

0 commit comments

Comments
 (0)