2017-04-28 07:49:57 +00:00
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
});
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const tapbundle_classes_taptest_1 = require("./tapbundle.classes.taptest");
|
2017-07-05 22:06:18 +00:00
|
|
|
const tapbundle_classes_tapwrap_1 = require("./tapbundle.classes.tapwrap");
|
2017-04-28 07:49:57 +00:00
|
|
|
class Tap {
|
|
|
|
constructor() {
|
2017-07-05 22:06:18 +00:00
|
|
|
/**
|
|
|
|
* skip a test
|
|
|
|
*/
|
2017-04-28 09:00:22 +00:00
|
|
|
this.skip = {
|
2017-07-05 22:06:18 +00:00
|
|
|
test: (descriptionArg, functionArg) => {
|
|
|
|
console.log(`skipped test: ${descriptionArg}`);
|
2017-04-28 09:00:22 +00:00
|
|
|
}
|
|
|
|
};
|
2017-04-28 07:49:57 +00:00
|
|
|
this._tests = [];
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Normal test function, will run one by one
|
|
|
|
* @param testDescription - A description of what the test does
|
|
|
|
* @param testFunction - A Function that returns a Promise and resolves or rejects
|
|
|
|
*/
|
|
|
|
test(testDescription, testFunction) {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
let localTest = new tapbundle_classes_taptest_1.TapTest({
|
|
|
|
description: testDescription,
|
|
|
|
testFunction: testFunction,
|
|
|
|
parallel: false
|
|
|
|
});
|
|
|
|
this._tests.push(localTest);
|
|
|
|
return localTest;
|
|
|
|
});
|
|
|
|
}
|
2017-07-05 22:06:18 +00:00
|
|
|
/**
|
|
|
|
* wraps function
|
|
|
|
*/
|
|
|
|
wrap(functionArg) {
|
|
|
|
return new tapbundle_classes_tapwrap_1.TapWrap(functionArg);
|
|
|
|
}
|
2017-04-28 07:49:57 +00:00
|
|
|
/**
|
|
|
|
* A parallel test that will not be waited for before the next starts.
|
|
|
|
* @param testDescription - A description of what the test does
|
|
|
|
* @param testFunction - A Function that returns a Promise and resolves or rejects
|
|
|
|
*/
|
|
|
|
testParallel(testDescription, testFunction) {
|
|
|
|
this._tests.push(new tapbundle_classes_taptest_1.TapTest({
|
|
|
|
description: testDescription,
|
|
|
|
testFunction: testFunction,
|
|
|
|
parallel: true
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* tests leakage
|
|
|
|
* @param testDescription - A description of what the test does
|
|
|
|
* @param testFunction - A Function that returns a Promise and resolves or rejects
|
|
|
|
*/
|
|
|
|
testLeakage(testDescription, testFunction) {
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* starts the test evaluation
|
|
|
|
*/
|
|
|
|
start() {
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
let promiseArray = [];
|
|
|
|
// safeguard against empty test array
|
|
|
|
if (this._tests.length === 0) {
|
|
|
|
console.log('no tests specified. Ending here!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
console.log(`1..${this._tests.length}`);
|
|
|
|
for (let testKey = 0; testKey < this._tests.length; testKey++) {
|
|
|
|
let currentTest = this._tests[testKey];
|
|
|
|
let testPromise = currentTest.run(testKey);
|
|
|
|
if (currentTest.parallel) {
|
|
|
|
promiseArray.push(testPromise);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
yield testPromise;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
yield Promise.all(promiseArray);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* handle errors
|
|
|
|
*/
|
|
|
|
threw(err)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