"use strict";
var Glob = require("glob");
var path = require("path");
var TestSet = (function () {
function TestSet(testsFileLocations) {
this._testFixtures = [];
Iif (typeof testsFileLocations === "string") {
testsFileLocations = [testsFileLocations];
}
this._loadTestFixtures(testsFileLocations);
if (this._testsFocussed) {
this._testFixtures = this._testFixtures.map(function (x) {
x.tests = x.tests.filter(function (y) { return y.focussed; });
return x;
}).filter(function (testFixture) { return testFixture.tests.length !== 0; });
}
}
Object.defineProperty(TestSet.prototype, "testFixtures", {
get: function () {
return this._testFixtures;
},
enumerable: true,
configurable: true
});
TestSet.prototype._loadTestFixtures = function (testFileLocations) {
var _this = this;
testFileLocations.forEach(function (testFileLocation) {
testFileLocation = path.join(process.cwd(), testFileLocation);
Eif (Glob.hasMagic(testFileLocation)) {
var physicalTestFileLocations = Glob.sync(testFileLocation);
physicalTestFileLocations.forEach(function (physicalTestFileLocation) {
_this._loadTest(require(physicalTestFileLocation));
});
}
else {
_this._loadTest(require(testFileLocation));
}
});
};
TestSet.prototype._loadTest = function (Test) {
var _this = this;
var testFixtureKeys = Object.keys(Test);
testFixtureKeys.forEach(function (testFixtureKey) {
Iif (Reflect.getMetadata("alsatian:ignore", Test[testFixtureKey])) {
return;
}
var testFixture = {};
testFixture.fixture = new Test[testFixtureKey]();
var tests = Reflect.getMetadata("alsatian:tests", testFixture.fixture);
Iif (!tests || tests.length === 0) {
return;
}
var focusFixture = Reflect.getMetadata("alsatian:focus", Test[testFixtureKey]);
testFixture.tests = [];
tests.forEach(function (test) {
Iif (Reflect.getMetadata("alsatian:ignore", testFixture.fixture, test.key)) {
return;
}
var focusTest = Reflect.getMetadata("alsatian:focus", testFixture.fixture, test.key);
test.focussed = focusFixture || focusTest;
_this._testsFocussed = _this._testsFocussed || test.focussed;
testFixture.tests.push(test);
Eif (!test.description) {
test.description = test.key;
}
var testCases = Reflect.getMetadata("alsatian:testcases", testFixture.fixture, test.key);
test.testCases = [];
if (!testCases) {
test.testCases.push([]);
}
else {
testCases.forEach(function (testCase) {
test.testCases.push(testCase);
});
}
});
_this._testFixtures.push(testFixture);
});
};
return TestSet;
}());
exports.TestSet = TestSet;
//# sourceMappingURL=test-set.js.map |