selenium-state-machine
Version:
Write Selenium tests using state machines
40 lines (39 loc) • 1.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.describe = void 0;
const mocha_1 = require("mocha");
const Fsm_1 = require("./Fsm");
function describe(name, dependencies, timeout, func) {
let fsm;
(0, mocha_1.describe)(name, function () {
this.timeout(timeout + 2000);
(0, mocha_1.before)('Create pipeline', async function () {
fsm = new Fsm_1.Fsm({ timeout }, dependencies);
const namedRegister = registerNamedFactory(fsm);
const register = registerFactory(fsm);
await func(namedRegister, register);
});
(0, mocha_1.it)('Pipeline works', async function () {
await fsm.start();
});
(0, mocha_1.after)('Clear pipeline', function () {
fsm.stop();
});
});
}
exports.describe = describe;
function registerNamedFactory(pipe) {
return function (name, func) {
if (typeof name === 'string') {
pipe.namedState(name, func);
}
else {
pipe.state(func);
}
};
}
function registerFactory(pipe) {
return function (func) {
pipe.state(func);
};
}