@gatling.io/mqtt
Version:
Gatling JS is a JavaScript/TypeScript interface for the [Gatling load testing tool](https://gatling.io/).
65 lines (64 loc) • 3.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PublishActionBuilder = void 0;
const core_1 = require("@gatling.io/core");
var PublishActionBuilder;
(function (PublishActionBuilder) {
PublishActionBuilder.wrapBase = (_underlying) => ({
message: (body) => wrapPublishActionBuilder(_underlying.message(body._underlying))
});
PublishActionBuilder.wrapCheckable = (_underlying) => ({
_underlying,
qosAtMostOnce: () => wrapPublishActionBuilder(_underlying.qosAtMostOnce()),
qosAtLeastOnce: () => wrapPublishActionBuilder(_underlying.qosAtMostOnce()),
qosExactlyOnce: () => wrapPublishActionBuilder(_underlying.qosExactlyOnce()),
check: (...checks) => PublishActionBuilder.wrapCheckable(_underlying.check(checks.map((cb) => cb._underlying)))
});
})(PublishActionBuilder || (exports.PublishActionBuilder = PublishActionBuilder = {}));
const wrapPublishActionBuilder = (_underlying) => ({
_underlying,
qosAtMostOnce: () => wrapPublishActionBuilder(_underlying.qosAtMostOnce()),
qosAtLeastOnce: () => wrapPublishActionBuilder(_underlying.qosAtLeastOnce()),
qosExactlyOnce: () => wrapPublishActionBuilder(_underlying.qosExactlyOnce()),
// Checkable
await: (timeout, expectedTopic) => {
if (expectedTopic !== undefined) {
if ((0, core_1.isDuration)(timeout)) {
const jvmTimeout = (0, core_1.toJvmDuration)(timeout);
if (typeof expectedTopic === "function") {
return PublishActionBuilder.wrapCheckable(_underlying.await(jvmTimeout, (0, core_1.underlyingSessionTo)(expectedTopic)));
}
else {
return PublishActionBuilder.wrapCheckable(_underlying.await(jvmTimeout, expectedTopic));
}
}
throw Error(`await() called with invalid arguments ${timeout}, ${expectedTopic}`);
}
else {
if ((0, core_1.isDuration)(timeout)) {
return PublishActionBuilder.wrapCheckable(_underlying.await((0, core_1.toJvmDuration)(timeout)));
}
throw Error(`await() called with invalid argument ${timeout}`);
}
},
expect: (timeout, expectedTopic) => {
if (expectedTopic !== undefined) {
if ((0, core_1.isDuration)(timeout)) {
const jvmTimeout = (0, core_1.toJvmDuration)(timeout);
if (typeof expectedTopic === "function") {
return PublishActionBuilder.wrapCheckable(_underlying.expect(jvmTimeout, (0, core_1.underlyingSessionTo)(expectedTopic)));
}
else {
return PublishActionBuilder.wrapCheckable(_underlying.expect(jvmTimeout, expectedTopic));
}
}
throw Error(`expect() called with invalid arguments ${timeout}, ${expectedTopic}`);
}
else {
if ((0, core_1.isDuration)(timeout)) {
return PublishActionBuilder.wrapCheckable(_underlying.expect((0, core_1.toJvmDuration)(timeout)));
}
throw Error(`expect() called with invalid argument ${timeout}`);
}
}
});