@averagehelper/corde
Version:
A simple library for Discord bot tests. (Republished fork to demonstrate a bugfix)
43 lines (42 loc) • 1.77 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.test = void 0;
const testCollector_1 = require("../common/testCollector");
const AsyncFunction = (() => __awaiter(void 0, void 0, void 0, function* () { })).constructor;
/**
* Represents a group of commands.
*
* @example
*
* test('Hello command should return... hello!!', () => {
* expect('hello').toReturn('hello!!');
* });
*
* @param name Name of the test
* @param action Commands related to this test
* @since 1.0
*/
function test(name, action) {
testCollector_1.testCollector.addToTestClousure(() => __awaiter(this, void 0, void 0, function* () {
testCollector_1.testCollector.hasTest = true;
if (action) {
yield action();
testCollector_1.testCollector.tests.push({
name,
testsFunctions: testCollector_1.testCollector.cloneTestFunctions(),
});
}
testCollector_1.testCollector.testsFunctions = [];
testCollector_1.testCollector.hasTest = false;
}));
}
exports.test = test;