kuzzle-sdk
Version:
Official Javascript SDK for Kuzzle
42 lines • 1.47 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const cucumber_1 = require("@cucumber/cucumber");
const should_1 = __importDefault(require("should"));
(0, cucumber_1.Given)(/^I subscribe to '(.*?)'(?: with '(.*)' as filter)?$/, async function (collection, filter) {
const parsedFilter = filter ? JSON.parse(filter) : {};
this.content = await this.kuzzle.realtime.subscribe(this.index, collection, parsedFilter, this.callback);
});
(0, cucumber_1.Given)("I unsubscribe", async function () {
await this.kuzzle.realtime.unsubscribe(this.content);
});
(0, cucumber_1.When)("I publish a document", async function () {
await this.kuzzle.realtime.publish(this.index, this.collection, {
a: "document",
});
});
(0, cucumber_1.Then)("I receive a notification", function (cb) {
setTimeout(() => {
try {
(0, should_1.default)(this.notifications.length).eql(1);
cb();
}
catch (e) {
cb(e);
}
}, 1000);
});
(0, cucumber_1.Then)("I do not receive a notification", function (cb) {
setTimeout(() => {
try {
(0, should_1.default)(this.notifications.length).eql(0);
cb();
}
catch (e) {
cb(e);
}
}, 1000);
});
//# sourceMappingURL=realtime.js.map