kuzzle-sdk
Version:
Official Javascript SDK for Kuzzle
66 lines • 2.33 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)("there is an index {string}", async function (index) {
const exists = await this.kuzzle.index.exists(index);
if (!exists) {
await this.kuzzle.index.create(index);
}
this.index = index;
});
(0, cucumber_1.Given)("there is no index called {string}", async function (index) {
try {
this.content = await this.kuzzle.index.delete(index);
}
catch {
/* do nothing */
}
});
(0, cucumber_1.Given)("there is the indexes {string} and {string}", async function (index1, index2) {
const ensureIndex = async (index) => {
const exists = await this.kuzzle.index.exists(index);
if (!exists) {
await this.kuzzle.index.create(index);
await this.kuzzle.collection.create(index, "a-collection", {});
}
};
await ensureIndex(index1);
await ensureIndex(index2);
});
(0, cucumber_1.When)("I create an index called {string}", async function (index) {
try {
this.content = await this.kuzzle.index.create(index);
this.index = index;
}
catch (error) {
this.error = error;
}
});
(0, cucumber_1.When)("I delete the indexes {string} and {string}", async function (index1, index2) {
this.content = await this.kuzzle.index.mDelete([index1, index2]);
});
(0, cucumber_1.When)("I list indexes", async function () {
try {
this.content = await this.kuzzle.index.list();
}
catch (error) {
this.error = error;
}
});
(0, cucumber_1.Then)("the index should exist", async function () {
const exists = await this.kuzzle.index.exists(this.index);
(0, should_1.default)(exists).be.true();
});
(0, cucumber_1.Then)("indexes {string} and {string} don't exist", async function (index1, index2) {
const check = async (index) => {
const exists = await this.kuzzle.index.exists(index);
(0, should_1.default)(exists).be.false();
};
await check(index1);
await check(index2);
});
//# sourceMappingURL=index.js.map