UNPKG

@pact-foundation/pact

Version:
69 lines 2.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UnconfiguredInteraction = void 0; const matchers_1 = require("../../v3/matchers"); const interactionWithPlugin_1 = require("./interactionWithPlugin"); const interactionWithRequest_1 = require("./interactionWithRequest"); const requestBuilder_1 = require("./requestBuilder"); class UnconfiguredInteraction { 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; } uponReceiving(description) { this.interaction.uponReceiving(description); return this; } given(state, parameters) { if (parameters) { this.interaction.givenWithParams(state, JSON.stringify(parameters)); } else { this.interaction.given(state); } return this; } pending(pending = true) { this.interaction.setPending(pending); return this; } comment(comment) { if (typeof comment === 'string') { this.interaction.addTextComment(comment); return this; } this.interaction.setComment(comment.key, comment.value); return this; } testName(name) { this.interaction.setInteractionTestName(name); return this; } reference(group, name, value) { this.interaction.addInteractionReference(group, name, value); return this; } withCompleteRequest(_request) { throw new Error('withCompleteRequest is not implemented'); } withRequest(method, path, builder) { this.interaction.withRequest(method, (0, matchers_1.matcherValueOrString)(path)); if (builder) { builder(new requestBuilder_1.RequestBuilder(this.interaction)); } return new interactionWithRequest_1.InteractionWithRequest(this.pact, this.interaction, this.opts, this.cleanupFn); } usingPlugin(config) { this.pact.addPlugin(config.plugin, config.version); return new interactionWithPlugin_1.InteractionWithPlugin(this.pact, this.interaction, this.opts, this.cleanupFn); } } exports.UnconfiguredInteraction = UnconfiguredInteraction; //# sourceMappingURL=unconfiguredInteraction.js.map