-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(import-alias):Test case updated
Signed-off-by: Jaskeerat Singh Saluja <[email protected]>
- Loading branch information
Jaskeerat Singh Saluja
authored and
Jaskeerat Singh Saluja
committed
Sep 5, 2024
1 parent
f2c6d63
commit a6d615f
Showing
1 changed file
with
20 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -386,10 +386,19 @@ describe('TypescriptVisitor', function () { | |
} | ||
}; | ||
|
||
let property2 = { | ||
isPrimitive: () => { | ||
return false; | ||
}, | ||
getFullyQualifiedTypeName: () => { | ||
return 'org.test.complex.file'; | ||
} | ||
}; | ||
|
||
let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration); | ||
|
||
mockClassDeclaration.isClassDeclaration.returns(true); | ||
mockClassDeclaration.getProperties.returns([property1]); | ||
mockClassDeclaration.getProperties.returns([property1, property2]); | ||
mockClassDeclaration.getNamespace.returns('org.test.collection'); | ||
mockClassDeclaration.getName.returns('folder'); | ||
|
||
|
@@ -401,26 +410,32 @@ describe('TypescriptVisitor', function () { | |
{ | ||
'$class': '[email protected]', | ||
types: ['document', 'file'], | ||
namespace:'org.test.basic', | ||
namespace: 'org.test.basic', | ||
aliasedTypes: [ | ||
{ | ||
name: 'file', | ||
aliasedName: 'f' | ||
} | ||
] | ||
}, | ||
{ | ||
'$class': '[email protected]', | ||
types: ['file'], | ||
namespace: 'org.test.complex', | ||
} | ||
]; | ||
|
||
mockModelFile.getAllDeclarations.returns([mockClassDeclaration]); | ||
mockModelFile.getImports.returns(['org.test.basic.file','org.test.basic.document']); | ||
mockModelFile.getImports.returns(['org.test.basic.file', 'org.test.basic.document', 'org.test.complex.file']); | ||
typescriptVisitor.visitModelFile(mockModelFile,param); | ||
|
||
param.fileWriter.writeLine.callCount.should.deep.equal(5); | ||
param.fileWriter.writeLine.callCount.should.deep.equal(6); | ||
param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, '/* eslint-disable @typescript-eslint/no-empty-interface */']); | ||
param.fileWriter.writeLine.getCall(1).args.should.deep.equal([0, '// Generated code for namespace: org.test.collection']); | ||
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, '\n// imports']); | ||
param.fileWriter.writeLine.getCall(3).args.should.deep.equal([0, 'import {Ifile as If} from \'./org.test.basic\';']); | ||
param.fileWriter.writeLine.getCall(4).args.should.deep.equal([0, '\n// interfaces']); | ||
param.fileWriter.writeLine.getCall(4).args.should.deep.equal([0, 'import {Ifile} from \'./org.test.complex\';']); | ||
param.fileWriter.writeLine.getCall(5).args.should.deep.equal([0, '\n// interfaces']); | ||
param.fileWriter.closeFile.calledOnce.should.be.ok; | ||
|
||
}); | ||
|