@pact-foundation/pact
Version:
Pact for all things Javascript
32 lines • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.InteractionWithPluginRequest = void 0;
const interactionWithPluginResponse_1 = require("./interactionWithPluginResponse");
const responseWithPluginBuilder_1 = require("./responseWithPluginBuilder");
const matchers_1 = require("../../v3/matchers");
const matchingRules_1 = require("../../common/matchingRules");
class InteractionWithPluginRequest {
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 responseWithPluginBuilder_1.ResponseWithPluginBuilder(this.interaction));
}
return new interactionWithPluginResponse_1.InteractionWithPluginResponse(this.pact, this.opts, this.cleanupFn);
}
}
exports.InteractionWithPluginRequest = InteractionWithPluginRequest;
//# sourceMappingURL=interactionWithPluginRequest.js.map