@n1k1t/mock-server
Version:
Powerful util to setup mocks over HTTP APIs
41 lines • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const operator_1 = require("../models/operator");
const logger_1 = require("../../logger");
const logger = logger_1.Logger.build('Expectations.Operators.Root');
class RootExpectationOperator extends operator_1.ExpectationOperator {
constructor() {
super(...arguments);
this.compiled = (() => {
const extracted = this.extractNestedSchema(this.command);
if (!extracted) {
return null;
}
const Operator = this.operators[extracted.key];
return new Operator(this.operators, extracted.nested);
})();
}
get tags() {
return this.compiled?.tags ?? [];
}
match(context) {
try {
return this.compiled?.match(context) ?? false;
}
catch (error) {
logger.error('Got error on expectation matching', error?.stack ?? error);
return false;
}
}
manipulate(context) {
try {
return this.compiled?.manipulate(context) ?? context;
}
catch (error) {
logger.error('Got error on expectation manipulation', error?.stack ?? error);
return context;
}
}
}
exports.default = RootExpectationOperator;
//# sourceMappingURL=root.operator.js.map