@@ -2,7 +2,7 @@ import { expect } from 'chai';
22import * as path from 'path' ;
33import * as os from 'os' ;
44import * as fs from 'fs' ;
5- import { stub , restore , SinonStub } from 'sinon' ;
5+ import { stub , restore , SinonStub , createSandbox } from 'sinon' ;
66import * as utilities from '@contentstack/cli-utilities' ;
77import * as cliAm from '@contentstack/cli-asset-management' ;
88import 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} ) ;
0 commit comments