geninq
Version:
A JavaScript version of the Linq library for Generators
46 lines (45 loc) • 2.5 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
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) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SIt = exports.AIt = exports.ItThrows = exports.It = void 0;
require("./functions/geninq");
require("./functions/async");
function It(name, test, expected, start) {
it(name + " async", () => __awaiter(this, void 0, void 0, function* () {
return expect(yield test((start !== null && start !== void 0 ? start : [1, 2, 3]).geninq().async())).toEqual(expected);
}));
it(name + " sync", () => __awaiter(this, void 0, void 0, function* () { return expect(test((start !== null && start !== void 0 ? start : [1, 2, 3]).geninq())).toEqual(expected); }));
}
exports.It = It;
function ItThrows(name, test, expected, start) {
it(name + " async", () => __awaiter(this, void 0, void 0, function* () {
try {
yield test((start !== null && start !== void 0 ? start : [1, 2, 3]).geninq().async());
}
catch (err) {
expect(err).toEqual(expected);
return;
}
throw new Error("Test did not throw");
}));
it(name + " sync", () => __awaiter(this, void 0, void 0, function* () { return expect(() => test((start !== null && start !== void 0 ? start : [1, 2, 3]).geninq())).toThrow(expected); }));
}
exports.ItThrows = ItThrows;
function AIt(name, test, expected, start) {
it(name + " async", () => __awaiter(this, void 0, void 0, function* () {
return expect(yield test((start !== null && start !== void 0 ? start : [1, 2, 3]).geninq().async())).toEqual(expected);
}));
}
exports.AIt = AIt;
function SIt(name, test, expected, start) {
it(name + " sync", () => __awaiter(this, void 0, void 0, function* () { return expect(test((start !== null && start !== void 0 ? start : [1, 2, 3]).geninq())).toEqual(expected); }));
}
exports.SIt = SIt;