all files / dist/ TestStructureGenerator.js

93.33% Statements 28/30
100% Branches 5/5
81.82% Functions 9/11
96.55% Lines 28/29
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48    10× 10× 10× 10× 10×       10× 10×         10× 10× 10× 10×       10× 10×     10× 10×            
"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