@pact-foundation/pact
Version:
Pact for all things Javascript
51 lines • 1.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnconfiguredGraphQLInteraction = void 0;
const matchers_1 = require("../../v3/matchers");
const graphQLInteractionWithRequest_1 = require("./graphQLInteractionWithRequest");
const graphQLRequestBuilder_1 = require("./graphQLRequestBuilder");
class UnconfiguredGraphQLInteraction {
pact;
interaction;
opts;
cleanupFn;
graphQLRequest;
// tslint:disable:no-empty-function
constructor(pact, interaction, opts, cleanupFn) {
this.pact = pact;
this.interaction = interaction;
this.opts = opts;
this.cleanupFn = cleanupFn;
this.graphQLRequest = {};
}
withOperation(operation) {
this.graphQLRequest.operation = operation;
return this;
}
withVariables(variables) {
this.graphQLRequest.variables = variables;
return this;
}
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;
}
withRequest(method, path, builder) {
this.interaction.withRequest(method, (0, matchers_1.matcherValueOrString)(path));
if (builder) {
builder(new graphQLRequestBuilder_1.GraphQLRequestBuilder(this.interaction));
}
return new graphQLInteractionWithRequest_1.GraphQLInteractionWithRequest(this.pact, this.interaction, this.opts, this.cleanupFn, this.graphQLRequest);
}
}
exports.UnconfiguredGraphQLInteraction = UnconfiguredGraphQLInteraction;
//# sourceMappingURL=index.js.map