all files / dist/ TestGenerator.js

89.09% Statements 49/55
100% Branches 0/0
50% Functions 6/12
88.89% Lines 48/54
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71                                             
"use strict";
var typeInfo = require("ts-type-info");
var AssertionsClassGenerator_1 = require("./AssertionsClassGenerator");
var TransformOptions_1 = require("./TransformOptions");
var TestRunnerGenerator_1 = require("./TestRunnerGenerator");
var TestRunnerInterfaceGenerator_1 = require("./TestRunnerInterfaceGenerator");
var TestRunnerArgsCacheGenerator_1 = require("./TestRunnerArgsCacheGenerator");
var StructureDependencyGetter_1 = require("./StructureDependencyGetter");
var StateTestRunnerGenerator_1 = require("./StateTestRunnerGenerator");
var TestRunnerFactoryGenerator_1 = require("./TestRunnerFactoryGenerator");
var TestFunctionGenerator_1 = require("./TestFunctionGenerator");
var wrappers_1 = require("./wrappers");
var TestGenerator = (function () {
    function TestGenerator() {
        this.assertionsClassGenerator = new AssertionsClassGenerator_1.AssertionsClassGenerator();
        this.testRunnerInterfaceGenerator = new TestRunnerInterfaceGenerator_1.TestRunnerInterfaceGenerator();
        this.testRunnerArgsCacheGenerator = new TestRunnerArgsCacheGenerator_1.TestRunnerArgsCacheGenerator();
        this.structureDependencyGetter = new StructureDependencyGetter_1.StructureDependencyGetter();
        this.testRunnerGenerator = new TestRunnerGenerator_1.TestRunnerGenerator();
        this.stateTestRunnerGenerator = new StateTestRunnerGenerator_1.StateTestRunnerGenerator();
        this.testRunnerFactoryGenerator = new TestRunnerFactoryGenerator_1.TestRunnerFactoryGenerator();
        this.testFunctionGenerator = new TestFunctionGenerator_1.TestFunctionGenerator();
        var opts = {};
        this.transformOptions = new TransformOptions_1.TransformOptions(opts);
        this.wrapperFactory = new wrappers_1.WrapperFactory(this.transformOptions);
    }
    TestGenerator.prototype.addCustomTestTransform = function (condition, testWrite) {
        this.transformOptions.addCustomTestTransform({ condition: condition, testWrite: testWrite });
    };
    TestGenerator.prototype.addDefaultValue = function (condition, value) {
        this.transformOptions.addDefaultValueTransform({ condition: condition, value: value });
    };
    TestGenerator.prototype.addIgnorePropertyTransform = function (condition) {
        this.transformOptions.addIgnorePropertyTransform({ condition: condition });
    };
    TestGenerator.prototype.addIgnoreTypeTransform = function (condition) {
        this.transformOptions.addIgnoreTypeTransform({ condition: condition });
    };
    TestGenerator.prototype.addOptInPropertyTransform = function (condition) {
        this.transformOptions.addOptInPropertyTransform({ condition: condition });
    };
    // todo: separate transforms from tests
    // todo: have ability to add "it" message when writing test
    TestGenerator.prototype.addPropertyTransform = function (condition, propertyTransform, testWrite) {
        this.transformOptions.addPropertyTransform({ condition: condition, propertyTransform: propertyTransform, testWrite: testWrite });
    };
    TestGenerator.prototype.addTestStructureTransform = function (condition, transform) {
        this.transformOptions.addTestStructureTransform({ condition: condition, transform: transform });
    };
    TestGenerator.prototype.addTypeTransform = function (condition, typeTransform, testWrite) {
        this.transformOptions.addTypeTransform({ condition: condition, typeTransform: typeTransform, testWrite: testWrite });
    };
    TestGenerator.prototype.getTestFile = function (structures) {
        var _this = this;
        var testFile = typeInfo.createFile();
        this.assertionsClassGenerator.fillFile(testFile);
        this.testRunnerInterfaceGenerator.fillFile(testFile);
        this.testRunnerArgsCacheGenerator.fillFile(testFile);
        var structureWrappers = this.structureDependencyGetter.getAllStructures(structures.map(function (s) { return _this.wrapperFactory.getStructure(s); }));
        this.testRunnerFactoryGenerator.fillTestFile(testFile, structureWrappers);
        this.stateTestRunnerGenerator.fillTestFile(testFile, structureWrappers);
        this.testRunnerGenerator.fillTestFile(testFile, structureWrappers);
        this.testFunctionGenerator.fillTestFile(testFile, structureWrappers);
        return testFile;
    };
    return TestGenerator;
}());
exports.TestGenerator = TestGenerator;
 
//# sourceMappingURL=TestGenerator.js.map