UNPKG

@pact-foundation/pact

Version:
32 lines 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InteractionWithRequest = void 0; const interactionWithResponse_1 = require("./interactionWithResponse"); const responseBuilder_1 = require("./responseBuilder"); const matchers_1 = require("../../v3/matchers"); const matchingRules_1 = require("../../common/matchingRules"); class InteractionWithRequest { pact; interaction; opts; cleanupFn; // tslint:disable:no-empty-function constructor(pact, interaction, opts, cleanupFn) { this.pact = pact; this.interaction = interaction; this.opts = opts; this.cleanupFn = cleanupFn; } willRespondWith(status, builder) { this.interaction.withStatus((0, matchers_1.reify)(status)); if ((0, matchers_1.isStatusCodeMatcher)(status)) { this.interaction.withResponseMatchingRules(JSON.stringify((0, matchingRules_1.convertStatusMatcherToFFI)(status))); } if (typeof builder === 'function') { builder(new responseBuilder_1.ResponseBuilder(this.interaction)); } return new interactionWithResponse_1.InteractionWithResponse(this.pact, this.opts, this.cleanupFn); } } exports.InteractionWithRequest = InteractionWithRequest; //# sourceMappingURL=interactionWithRequest.js.map