UNPKG

@typed/test

Version:
35 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const types_1 = require("../types"); const createTest_1 = require("./createTest"); const getModifier_1 = require("./getModifier"); const updateModifier_1 = require("./updateModifier"); function describe(what, tests) { const hasOnly = tests.some(x => x[types_1.TYPED_TEST].modifier === 'only'); const allSkip = tests.every(x => x[types_1.TYPED_TEST].modifier === 'skip'); const modifier = hasOnly ? 'only' : allSkip ? 'skip' : void 0; const testsToRun = modifier === 'only' ? tests.map(x => (getModifier_1.getModifier(x) === 'only' ? x : updateModifier_1.updateModifier('skip', x))) : tests; const test = createTest_1.createTest(`${what}`, spec => { return Promise.all(testsToRun.map(t => { return t .runTest(Object.assign(Object.assign({}, spec), { skip: getModifier_1.getModifier(t) === 'skip' || spec.skip })) .then(r => (Object.assign(Object.assign({}, r), { name: t[types_1.TYPED_TEST].name }))); })).then(results => ({ type: 'group', results, name: test[types_1.TYPED_TEST].name })); }); return modifier ? updateModifier_1.updateModifier(modifier, test) : test; } exports.describe = describe; (function (describe) { function only(what, tests) { const test = describe(what, tests); return Object.assign(Object.assign({}, test), { [types_1.TYPED_TEST]: Object.assign(Object.assign({}, test[types_1.TYPED_TEST]), { modifier: 'only' }) }); } describe.only = only; function skip(what, tests) { return describe(what, tests.map(x => updateModifier_1.updateModifier('skip', x))); } describe.skip = skip; })(describe = exports.describe || (exports.describe = {})); //# sourceMappingURL=describe.js.map