@pact-foundation/pact
Version:
Pact for all things Javascript
40 lines • 2.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PactV4 = void 0;
var pact_core_1 = require("@pact-foundation/pact-core");
var http_1 = require("./http");
var package_json_1 = require("../../package.json");
var message_1 = require("./message");
var v3_1 = require("../v3");
var PactV4 = /** @class */ (function () {
function PactV4(opts) {
this.opts = opts;
this.setup();
this.pact.addMetadata('pact-js', 'version', package_json_1.version);
}
PactV4.prototype.setup = function () {
var _a, _b;
this.pact = (0, pact_core_1.makeConsumerPact)(this.opts.consumer, this.opts.provider, (_a = this.opts.spec) !== null && _a !== void 0 ? _a : v3_1.SpecificationVersion.SPECIFICATION_VERSION_V4, (_b = this.opts.logLevel) !== null && _b !== void 0 ? _b : 'info');
};
PactV4.prototype.addInteraction = function () {
var _this = this;
return new http_1.UnconfiguredInteraction(this.pact, this.pact.newInteraction(''), this.opts, function () {
// This function needs to be called if the PactV4 object is to be re-used (commonly expected by users)
// Because of the type-state model used here, it's a bit awkward as we need to thread this through
// to children, ultimately to be called on the "executeTest" stage.
_this.setup();
});
};
PactV4.prototype.addSynchronousInteraction = function (description) {
var _this = this;
return new message_1.UnconfiguredSynchronousMessage(this.pact, this.pact.newSynchronousMessage(description), this.opts, function () {
// This function needs to be called if the PactV4 object is to be re-used (commonly expected by users)
// Because of the type-state model used here, it's a bit awkward as we need to thread this through
// to children, ultimately to be called on the "executeTest" stage.
_this.setup();
});
};
return PactV4;
}());
exports.PactV4 = PactV4;
//# sourceMappingURL=index.js.map