UNPKG

alsatian

Version:

TypeScript and JavaScript testing framework for beautiful and readable tests

52 lines 2.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path = require("path"); const _1 = require("./"); class TestSet { constructor(testLoader, globHelper) { this._testFixtures = []; if (testLoader === null || testLoader === undefined) { throw new TypeError("testLoader must not be null or undefined."); } if (globHelper === null || globHelper === undefined) { throw new TypeError("globHelper must not be null or undefined."); } this._testLoader = testLoader; this._globHelper = globHelper; } static create() { const fileRequirer = new _1.FileRequirer(); const testLoader = new _1.TestLoader(fileRequirer); const globHelper = new _1.GlobHelper(); return new TestSet(testLoader, globHelper); } get testFixtures() { return this._testFixtures; } addTestsFromFiles(testsFileLocations) { let locationArray; if (typeof testsFileLocations === "string") { locationArray = [testsFileLocations]; } else { locationArray = testsFileLocations; } this._loadTestFixtures(locationArray); } _loadTestFixtures(testFileLocations) { testFileLocations.forEach(testFileLocation => { testFileLocation = path.resolve(testFileLocation); if (this._globHelper.isGlob(testFileLocation)) { const physicalTestFileLocations = this._globHelper.resolve(testFileLocation); physicalTestFileLocations.forEach(physicalTestFileLocation => { this._testFixtures = this.testFixtures.concat(this._testLoader.loadTestFixture(physicalTestFileLocation)); }); } else { this._testFixtures = this.testFixtures.concat(this._testLoader.loadTestFixture(testFileLocation)); } }); } } exports.TestSet = TestSet; //# sourceMappingURL=test-set.js.map