Innovenergy_trunk/frontend/node_modules/testcafe/lib/custom-client-scripts/routing.js

37 lines
4.4 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.unRegister = exports.register = exports.isLegacyTest = void 0;
const get_url_1 = __importDefault(require("./get-url"));
const get_code_1 = __importDefault(require("./get-code"));
const content_types_1 = __importDefault(require("../assets/content-types"));
function isLegacyTest(test) {
return !!test.isLegacy;
}
exports.isLegacyTest = isLegacyTest;
function register(proxy, tests, proxyless) {
const routes = [];
tests.forEach(test => {
if (isLegacyTest(test))
return;
test.clientScripts.forEach((script) => {
const route = (0, get_url_1.default)(script);
proxy.GET(route, {
content: (0, get_code_1.default)(script, proxyless),
contentType: content_types_1.default.javascript,
});
routes.push(route);
});
});
return routes;
}
exports.register = register;
function unRegister(proxy, routes) {
routes.forEach(route => {
proxy.unRegisterRoute(route, 'GET');
});
}
exports.unRegister = unRegister;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm91dGluZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jdXN0b20tY2xpZW50LXNjcmlwdHMvcm91dGluZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSx3REFBaUQ7QUFDakQsMERBQW1EO0FBQ25ELDRFQUFvRDtBQWVwRCxTQUFnQixZQUFZLENBQUUsSUFBYztJQUN4QyxPQUFPLENBQUMsQ0FBRSxJQUFtQixDQUFDLFFBQVEsQ0FBQztBQUMzQyxDQUFDO0FBRkQsb0NBRUM7QUFFRCxTQUFnQixRQUFRLENBQUUsS0FBWSxFQUFFLEtBQWEsRUFBRSxTQUFrQjtJQUNyRSxNQUFNLE1BQU0sR0FBYSxFQUFFLENBQUM7SUFFNUIsS0FBSyxDQUFDLE9BQU8sQ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