Innovenergy_trunk/frontend/node_modules/testcafe/lib/role/index.js

27 lines
4.1 KiB
JavaScript
Raw Permalink 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 });
exports.createAnonymousRole = exports.createRole = void 0;
const type_assertions_1 = require("../errors/runtime/type-assertions");
const wrap_test_function_1 = __importDefault(require("../api/wrap-test-function"));
const test_page_url_1 = require("../api/test-page-url");
const role_1 = __importDefault(require("./role"));
function createRole(loginUrl, initFn, options = { preserveUrl: false }) {
(0, type_assertions_1.assertType)(type_assertions_1.is.string, 'Role', 'The "loginUrl" argument', loginUrl);
(0, type_assertions_1.assertType)(type_assertions_1.is.function, 'Role', 'The "initFn" argument', initFn);
(0, type_assertions_1.assertType)(type_assertions_1.is.nonNullObject, 'Role', 'The "options" argument', options);
if (options.preserveUrl !== void 0)
(0, type_assertions_1.assertType)(type_assertions_1.is.boolean, 'Role', 'The "preserveUrl" option', options.preserveUrl);
(0, test_page_url_1.assertRoleUrl)(loginUrl, 'Role');
loginUrl = (0, test_page_url_1.getUrl)(loginUrl);
initFn = (0, wrap_test_function_1.default)(initFn);
return new role_1.default(loginUrl, initFn, options);
}
exports.createRole = createRole;
function createAnonymousRole() {
return new role_1.default(null, null);
}
exports.createAnonymousRole = createAnonymousRole;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcm9sZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSx1RUFBbUU7QUFDbkUsbUZBQXlEO0FBQ3pELHdEQUE2RDtBQUM3RCxrREFBMEI7QUFNMUIsU0FBZ0IsVUFBVSxDQUFFLFFBQWdCLEVBQUUsTUFBZ0IsRUFBRSxVQUF1QixFQUFFLFdBQVcsRUFBRSxL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