Skip to content

Commit cc72b0e

Browse files
update import test
1 parent ce3b549 commit cc72b0e

File tree

1 file changed

+5
-15
lines changed
  • packages/contentstack-import/test/unit/commands/cm/stacks

1 file changed

+5
-15
lines changed

packages/contentstack-import/test/unit/commands/cm/stacks/import.test.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from 'chai';
22
import { fancy } from 'fancy-test';
33
import 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';
55
import ImportCommand from '../../../../../src/commands/cm/stacks/import';
66
import { ModuleImporter } from '../../../../../src/import';
77
import { 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

Comments
 (0)