Skip to content

Commit

Permalink
feat(alias-import):Test cases added
Browse files Browse the repository at this point in the history
Signed-off-by: Jaskeerat Singh Saluja <[email protected]>
  • Loading branch information
Jaskeerat Singh Saluja authored and Jaskeerat Singh Saluja committed Sep 6, 2024
1 parent 782cff8 commit 427d3db
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/codegen/fromcto/typescript/typescriptvisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,34 @@ describe('TypescriptVisitor', function () {
param.fileWriter.writeLine.getCall(1).args.should.deep.equal([1, '$class: string;']);
param.fileWriter.writeLine.getCall(2).args.should.deep.equal([0, '}\n']);
});

it('should write lines for the extending class declaration using aliased types ', () => {

let property = {
isPrimitive: () => {
return false;
},
getFullyQualifiedTypeName: () => {
return 'org.test.basic.file';
}
};

let mockClassDeclaration = sinon.createStubInstance(ClassDeclaration);

mockClassDeclaration.isClassDeclaration.returns(true);
mockClassDeclaration.getProperties.returns([property]);
mockClassDeclaration.getNamespace.returns('org.test.collection');
mockClassDeclaration.getName.returns('bigFile');
mockClassDeclaration.getSuperType.returns('org.basic.file');
mockClassDeclaration.isScalarDeclaration.returns(false);
mockClassDeclaration.getDirectSubclasses.returns([]);
mockClassDeclaration.getOwnProperties.returns([]);
param.aliasedTypesMap = new Map([['org.basic.Ifile', 'If']]);
typescriptVisitor.visitClassDeclaration(mockClassDeclaration,param);

param.fileWriter.writeLine.callCount.should.deep.equal(2);
param.fileWriter.writeLine.getCall(0).args.should.deep.equal([0, 'export interface IbigFile extends If {']);
});
});

describe('visitField', () => {
Expand Down

0 comments on commit 427d3db

Please sign in to comment.