e2ed
Version:
E2E testing framework over Playwright
30 lines (29 loc) • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addRequests = void 0;
const asserts_1 = require("../asserts");
const object_1 = require("../object");
const addRequestStatistics_1 = require("./addRequestStatistics");
/**
* Adds additional requests to total API statistics requests.
* @internal
*/
const addRequests = (targetByUrl, sourceByUrl) => {
for (const url of (0, object_1.getKeys)(sourceByUrl)) {
const sourceByMethod = sourceByUrl[url];
(0, asserts_1.assertValueIsDefined)(sourceByMethod, 'sourceByMethod is defined', { sourceByUrl, url });
let targetByMethod = targetByUrl[url];
targetByMethod ??= (0, object_1.setReadonlyProperty)(targetByUrl, url, Object.create(null));
for (const method of (0, object_1.getKeys)(sourceByMethod)) {
const sourceByStatusCode = sourceByMethod[method];
(0, asserts_1.assertValueIsDefined)(sourceByStatusCode, 'sourceByStatusCode is defined', { method, url });
let targetByStatusCode = targetByMethod[method];
if (targetByStatusCode === undefined) {
targetByStatusCode = Object.create(null);
(0, object_1.setReadonlyProperty)(targetByMethod, method, targetByStatusCode);
}
(0, addRequestStatistics_1.addRequestStatistics)(targetByStatusCode, sourceByStatusCode);
}
}
};
exports.addRequests = addRequests;