"use strict";
var TestStructureGenerator = (function () {
function TestStructureGenerator(typeTransformer) {
this.typeTransformer = typeTransformer;
}
TestStructureGenerator.prototype.fillTestFileFromDefinition = function (testFile, structure) {
var testStructure = testFile.addInterface({ name: structure.getTestStructureName(), isExported: true });
this.fillTestStructureTypeParameters(structure, testStructure);
this.fillTestStructureProperties(structure, testStructure);
this.addExtendsTypes(structure, testStructure);
structure.getTestStructureTransforms().forEach(function (transform) {
transform.transform(testStructure);
});
};
TestStructureGenerator.prototype.fillTestStructureTypeParameters = function (structure, testStructure) {
var _this = this;
structure.getTypeParameters().forEach(function (typeParam) {
var newTypeParam = testStructure.addTypeParameter({
name: typeParam.getName()
});
var constraintType = typeParam.getConstraintType();
newTypeParam.constraintType = constraintType == null ? null : _this.typeTransformer.getNewType(constraintType);
});
};
TestStructureGenerator.prototype.fillTestStructureProperties = function (structure, testStructure) {
var _this = this;
structure.getProperties().forEach(function (prop) {
var propertyTransforms = prop.getMatchedPropertyTransforms();
var newProp = testStructure.addProperty({
name: prop.getName(),
isOptional: prop.getIsOptional() || prop.getMatchedDefaultTransforms().length > 0 || prop.hasMatchedOptInTransforms()
});
newProp.type = _this.typeTransformer.getNewType(prop.getType());
propertyTransforms.forEach(function (transform) { return transform.propertyTransform(newProp); });
});
};
TestStructureGenerator.prototype.addExtendsTypes = function (structure, testStructure) {
var extendsTypes = structure.getValidExtendsTypes();
extendsTypes.forEach(function (extendsType) {
testStructure.addExtends(extendsType.getTestStructureName());
});
};
return TestStructureGenerator;
}());
exports.TestStructureGenerator = TestStructureGenerator;
//# sourceMappingURL=TestStructureGenerator.js.map
|