1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const path = require("path");
|
4 | const _1 = require("./");
|
5 | class 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 | }
|
51 | exports.TestSet = TestSet;
|
52 |
|
\ | No newline at end of file |