@ply-ct/ply
Version:
REST API Automated Testing
38 lines • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DelayExec = void 0;
const exec_1 = require("./exec");
class DelayExec extends exec_1.StepExec {
async run(context) {
var _a;
let interval = (_a = context.step.attributes) === null || _a === void 0 ? void 0 : _a.interval;
if (interval) {
if (this.isExpression(interval)) {
interval = context.evaluateToString(interval);
}
const ms = Number(interval);
if (isNaN(ms)) {
return { status: 'Errored', message: `Bad value for 'interval': ${interval}` };
}
context.logDebug(`Delaying ${ms} ms`);
await this.delay(ms);
return { status: 'Passed' };
}
else {
return { status: 'Errored', message: 'Missing attribute: interval' };
}
}
delay(ms) {
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, ms);
});
}
isTrustRequired(context) {
var _a;
return this.isExpression(((_a = context.step.attributes) === null || _a === void 0 ? void 0 : _a.interval) || '');
}
}
exports.DelayExec = DelayExec;
//# sourceMappingURL=delay.js.map