UNPKG

wiremock-captain

Version:

A better way to use the WireMock simulator to test your HTTP APIs

33 lines (32 loc) 1.33 kB
"use strict"; // Copyright (c) WarnerMedia Direct, LLC. All rights reserved. Licensed under the MIT license. // See the LICENSE file for license information. Object.defineProperty(exports, "__esModule", { value: true }); exports.filterRequest = filterRequest; exports.getWebhookBody = getWebhookBody; exports.getWebhookDelayBody = getWebhookDelayBody; const externalTypes_1 = require("./types/externalTypes"); // eslint-disable-next-line @typescript-eslint/no-explicit-any function filterRequest(method, endpointUrl, request) { return request.request.method === method && request.request.url === endpointUrl; } function getWebhookBody(body) { switch (body.type) { case 'JSON': return JSON.stringify(body.data); case 'String': return body.data; } } function getWebhookDelayBody(delay) { switch (delay.type) { case externalTypes_1.DelayType.FIXED: return { type: 'fixed', milliseconds: delay.constantDelay }; case externalTypes_1.DelayType.LOG_NORMAL: return { type: 'lognormal', median: delay.median, sigma: delay.sigma }; case externalTypes_1.DelayType.UNIFORM: return { type: 'uniform', lower: delay.lower, upper: delay.upper }; default: throw new Error('unsupported webhook delay type'); } }