UNPKG

2.02 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const path = require("path");
4const _1 = require("./");
5class TestSet {
6 constructor(testLoader, globHelper) {
7 this._testFixtures = [];
8 if (testLoader === null || testLoader === undefined) {
9 throw new TypeError("testLoader must not be null or undefined.");
10 }
11 if (globHelper === null || globHelper === undefined) {
12 throw new TypeError("globHelper must not be null or undefined.");
13 }
14 this._testLoader = testLoader;
15 this._globHelper = globHelper;
16 }
17 static create() {
18 const fileRequirer = new _1.FileRequirer();
19 const testLoader = new _1.TestLoader(fileRequirer);
20 const globHelper = new _1.GlobHelper();
21 return new TestSet(testLoader, globHelper);
22 }
23 get testFixtures() {
24 return this._testFixtures;
25 }
26 addTestsFromFiles(testsFileLocations) {
27 let locationArray;
28 if (typeof testsFileLocations === "string") {
29 locationArray = [testsFileLocations];
30 }
31 else {
32 locationArray = testsFileLocations;
33 }
34 this._loadTestFixtures(locationArray);
35 }
36 _loadTestFixtures(testFileLocations) {
37 testFileLocations.forEach(testFileLocation => {
38 testFileLocation = path.resolve(testFileLocation);
39 if (this._globHelper.isGlob(testFileLocation)) {
40 const physicalTestFileLocations = this._globHelper.resolve(testFileLocation);
41 physicalTestFileLocations.forEach(physicalTestFileLocation => {
42 this._testFixtures = this.testFixtures.concat(this._testLoader.loadTestFixture(physicalTestFileLocation));
43 });
44 }
45 else {
46 this._testFixtures = this.testFixtures.concat(this._testLoader.loadTestFixture(testFileLocation));
47 }
48 });
49 }
50}
51exports.TestSet = TestSet;
52//# sourceMappingURL=test-set.js.map
\No newline at end of file