Innovenergy_trunk/frontend/node_modules/testcafe/lib/api/request-hooks/hook.js

34 lines
6.0 KiB
JavaScript
Raw Permalink Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const testcafe_hammerhead_1 = require("testcafe-hammerhead");
const test_run_1 = require("../../errors/test-run");
class RequestHook {
constructor(ruleInit, responseEventConfigureOpts) {
this._requestFilterRules = this._prepareRules(ruleInit);
this._responseEventConfigureOpts = responseEventConfigureOpts;
this._warningLog = null;
this.id = (0, testcafe_hammerhead_1.generateUniqueId)();
this._className = this.constructor.name;
}
_prepareRules(ruleInit) {
if (Array.isArray(ruleInit) && !ruleInit.length)
return [];
const rules = testcafe_hammerhead_1.RequestFilterRule.fromArray(ruleInit);
return !rules.length ? [testcafe_hammerhead_1.RequestFilterRule.ANY] : rules;
}
async onRequest(event) {
throw new test_run_1.RequestHookNotImplementedMethodError('onRequest', this.constructor.name);
}
async _onConfigureResponse(event) {
if (!this._responseEventConfigureOpts)
return;
event.opts.includeHeaders = this._responseEventConfigureOpts.includeHeaders;
event.opts.includeBody = this._responseEventConfigureOpts.includeBody;
}
async onResponse(event) {
throw new test_run_1.RequestHookNotImplementedMethodError('onResponse', this.constructor.name);
}
}
exports.default = RequestHook;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaG9vay5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcGkvcmVxdWVzdC1ob29rcy9ob29rLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsNkRBUTZCO0FBRTdCLG9EQUE2RTtBQUk3RSxNQUE4QixXQUFXO0lBT3JDLFlBQXVCLFFBQTBELEVBQUUsMEJBQTBEO1FBQ3pJLElBQUksQ0FBQyxtQkFBbUIsR0FBVyxJQUFJLENBQUMsYUFBYSxDQUFDLFFBQVEsQ0FBQyxDQUFDO1FBQ2hFLElBQUksQ0FBQ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