11import { expect } from 'chai' ;
22import { fancy } from 'fancy-test' ;
33import sinon from 'sinon' ;
4- import { managementSDKClient , configHandler , log , handleAndLogError , getLogPath , createLogContext } from '@contentstack/cli-utilities' ;
4+ import { managementSDKClient , configHandler , log , handleAndLogError , getLogPath } from '@contentstack/cli-utilities' ;
55import ImportCommand from '../../../../../src/commands/cm/stacks/import' ;
66import { ModuleImporter } from '../../../../../src/import' ;
77import { ImportConfig } from '../../../../../src/types' ;
@@ -198,23 +198,14 @@ describe('ImportCommand', () => {
198198 } ) ;
199199 } ) ;
200200
201- describe ( 'createLogContext ' , ( ) => {
201+ describe ( 'createImportContext ' , ( ) => {
202202 let configHandlerStub : sinon . SinonStub ;
203- let configHandlerSetStub : sinon . SinonStub ;
204203
205204 beforeEach ( ( ) => {
206205 configHandlerStub = sinon . stub ( configHandler , 'get' ) ;
207- configHandlerSetStub = sinon . stub ( configHandler , 'set' ) ;
208- configHandlerStub . withArgs ( 'clientId' ) . returns ( 'user-123' ) ;
206+ configHandlerStub . withArgs ( 'userUid' ) . returns ( 'user-123' ) ;
209207 configHandlerStub . withArgs ( 'email' ) . returns ( 'test@example.com' ) ;
210- configHandlerStub . withArgs ( 'sessionId' ) . returns ( 'test-session-123' ) ;
211208 configHandlerStub . withArgs ( 'oauthOrgUid' ) . returns ( 'org-123' ) ;
212- configHandlerStub . withArgs ( 'authorisationType' ) . returns ( 'BASIC' ) ;
213- } ) ;
214-
215- afterEach ( ( ) => {
216- configHandlerStub . restore ( ) ;
217- configHandlerSetStub . restore ( ) ;
218209 } ) ;
219210
220211 it ( 'should create context with all required properties' , ( ) => {
@@ -228,7 +219,6 @@ describe('ImportCommand', () => {
228219 expect ( context ) . to . have . property ( 'apiKey' , 'test' ) ;
229220 expect ( context ) . to . have . property ( 'orgId' , 'org-123' ) ;
230221 expect ( context ) . to . have . property ( 'authenticationMethod' , 'Basic Auth' ) ;
231- expect ( configHandlerSetStub . calledWith ( 'apiKey' , 'test' ) ) . to . be . true ;
232222 } ) ;
233223
234224 it ( 'should use default authentication method when not provided' , ( ) => {
@@ -524,7 +514,6 @@ describe('ImportCommand', () => {
524514 const context = command [ 'createImportContext' ] ( 'test' ) ;
525515
526516 expect ( context . command ) . to . equal ( 'cm:stacks:import' ) ;
527- expect ( context . sessionId ) . to . equal ( 'test-session' ) ;
528517 } ) ;
529518
530519 it ( 'should handle context without sessionId' , ( ) => {
@@ -535,7 +524,8 @@ describe('ImportCommand', () => {
535524 expect ( context . sessionId ) . to . be . undefined ;
536525 } ) ;
537526
538- it ( 'should handle configHandler returning undefined values' , ( ) => {
527+ it ( 'should handle configHandler throwing errors' , ( ) => {
528+ configHandlerStub . reset ( ) ;
539529 configHandlerStub . returns ( undefined ) ;
540530
541531 const context = command [ 'createImportContext' ] ( 'test' ) ;
0 commit comments