corde
Version:
A simple library for Discord bot tests
50 lines (39 loc) • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.group = void 0;
const testCollector_1 = require("../common/testCollector");
const utils_1 = require("../utils");
const group = (definitionResolvable, testDefinitions) => {
const _internalGroup = async () => {
testCollector_1.testCollector.isInsideGroupClausure = true;
if (testDefinitions) {
await testDefinitions();
await testCollector_1.testCollector.executeTestClojure();
const resolvedName = await (0, utils_1.resolveName)(definitionResolvable);
if (testCollector_1.testCollector.tests && testCollector_1.testCollector.tests.length > 0) {
testCollector_1.testCollector.groups.push({
name: resolvedName,
tests: testCollector_1.testCollector.tests.map((test) => test),
});
}
if (testCollector_1.testCollector.isInsideTestClausureFunctions()) {
const testsCloned = testCollector_1.testCollector.cloneTestFunctions();
testCollector_1.testCollector.groups.push({
name: resolvedName,
tests: [
{
testsFunctions: testsCloned,
},
],
});
testCollector_1.testCollector.clearTestFunctions();
}
}
testCollector_1.testCollector.tests = [];
testCollector_1.testCollector.isInsideGroupClausure = false;
};
testCollector_1.testCollector.addToGroupClousure(async () => await _internalGroup());
};
exports.group = group;