all files / core/decorators/ async-test-decorator.js

100% Statements 16/16
100% Branches 4/4
100% Functions 4/4
100% Lines 14/14
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×   113×   113× 19×       922× 52×         993× 113× 113×   113×      
"use strict";
require("reflect-metadata");
var _metadata_keys_1 = require("./_metadata-keys");
function AsyncTest(description) {
    return function (target, propertyKey, descriptor) {
        // check if this has been registered as a test already
        var tests = Reflect.getMetadata(_metadata_keys_1.TESTS, target);
        // if there are no tests registered yet then register it
        if (!tests) {
            tests = [{
                    key: propertyKey
                }];
        }
        else if (tests.filter(function (test) { return test.key === propertyKey; }).length === 0) {
            tests.push({
                key: propertyKey
            });
        }
        // mark it as async and add the description
        var test = tests.filter(function (test) { return test.key === propertyKey; })[0];
        test.isAsync = true;
        test.description = description;
        // update the register
        Reflect.defineMetadata(_metadata_keys_1.TESTS, tests, target);
    };
}
exports.AsyncTest = AsyncTest;
//# sourceMappingURL=async-test-decorator.js.map