oral-ts
Version:
a testing framework for typescript
111 lines • 4.1 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Suite = void 0;
var events_1 = __importDefault(require("events"));
var ts_mixer_1 = require("ts-mixer");
function Suite(description) {
function whatDescription(constructor) {
var res;
if (description) {
res = description;
}
else
res = constructor;
return res;
}
return function (constructor) {
var assertions = new Set([]);
var utils = new Set([]);
var beforeEach = null;
var afterEach = null;
var beforeAll = null;
var afterAll = null;
var obj = new constructor();
var methods = [];
while ((obj = Reflect.getPrototypeOf(obj))) {
var keys = Reflect.ownKeys(obj);
keys.forEach(function (key) {
var role = Reflect.getMetadata("role", obj, key);
switch (role) {
case "util":
utils.add(key);
break;
case "assertion":
assertions.add(key);
break;
case "beforeAll":
beforeAll = key;
break;
case "afterAll":
afterAll = key;
break;
case "beforeEach":
beforeEach = key;
case "afterEach":
afterEach = key;
break;
}
});
}
return /** @class */ (function (_super) {
__extends(class_1, _super);
function class_1() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var _this = _super.apply(this, __spreadArray([], __read(args))) || this;
_this.suiteName = whatDescription(constructor.name);
_this.assertions = assertions;
_this.utils = utils;
_this.beforeAll = beforeAll;
_this.afterAll = afterAll;
_this.beforeEach = beforeEach;
_this.afterEach = afterEach;
return _this;
}
return class_1;
}(ts_mixer_1.Mixin(constructor, events_1.default)));
};
}
exports.Suite = Suite;
//# sourceMappingURL=suit.js.map