Innovenergy_trunk/frontend/node_modules/testcafe/lib/api/test-controller/custom-actions.js

42 lines
5.6 KiB
JavaScript
Raw Normal View History

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const get_callsite_1 = require("../../errors/get-callsite");
const actions_1 = require("../../test-run/commands/actions");
const delegated_api_1 = require("../../utils/delegated-api");
const delegated_api_2 = __importDefault(require("./delegated-api"));
class CustomActions {
constructor(testController, customActions) {
this._testController = testController;
this._customActions = customActions || {};
this._registerCustomActions();
}
_registerCustomActions() {
Object.entries(this._customActions).forEach(([name, fn]) => {
// @ts-ignore
this[(0, delegated_api_2.default)(name)] = (...args) => {
const callsite = (0, get_callsite_1.getCallsiteForMethod)(name) || void 0;
return this._testController.enqueueCommand(actions_1.RunCustomActionCommand, { fn, args, name }, this._validateCommand, callsite);
};
});
this._delegateAPI(this._customActions);
}
_validateCommand() {
return true;
}
_delegateAPI(actions) {
const customActionsList = Object.entries(actions).map(([name]) => {
return {
srcProp: (0, delegated_api_2.default)(name),
apiProp: name,
accessor: '',
};
});
(0, delegated_api_1.delegateAPI)(this, customActionsList, { useCurrentCtxAsHandler: true });
}
}
exports.default = CustomActions;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3VzdG9tLWFjdGlvbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBpL3Rlc3QtY29udHJvbGxlci9jdXN0b20tYWN0aW9ucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLDREQUFpRTtBQUNqRSw2REFBeUU7QUFDekUsNkRBQXdEO0FBR3hELG9FQUEyQztBQUUzQyxNQUFxQixhQUFhO0lBSTlCLFlBQWEsY0FBOEIsRUFBRSxhQUFtQztRQUM1RSxJQUFJLENBQUMsZUFBZSxHQUFHLGN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