1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-10-02 16:16:42 +02:00

v0.6.2 Improve Suggestion, Improve Coverage, Add Tests

This commit is contained in:
Thomas Wilkerling
2019-02-22 15:21:06 +01:00
parent 9434accfb3
commit 0997910f4d
13 changed files with 1853 additions and 311 deletions

View File

@@ -1,7 +1,6 @@
var env = "";
if(typeof module !== "undefined"){
var env = "pre";
var expect = require("chai").expect;
var FlexSearch = require("../" + (env ? "dist/": "") + "flexsearch" + (env ? "." + env : "") + ".js");
}
@@ -60,7 +59,6 @@ describe("Index Multi-Field Documents (ES6)", function(){
async: true,
doc: {
id: "id",
field: [
"data:title",
@@ -71,8 +69,11 @@ describe("Index Multi-Field Documents (ES6)", function(){
await index.add(data);
expect(index.doc.index["data:title"].length).to.equal(3);
expect(index.doc.index["data:body"].length).to.equal(3);
if(env === ""){
expect(index.doc.index["data:title"].length).to.equal(3);
expect(index.doc.index["data:body"].length).to.equal(3);
}
expect(await index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
@@ -106,8 +107,11 @@ describe("Index Multi-Field Documents (ES6)", function(){
await index.remove(update);
expect(await index.doc.index["data:title"].length).to.equal(0);
expect(await index.doc.index["data:body"].length).to.equal(0);
if(env === ""){
expect(await index.doc.index["data:title"].length).to.equal(0);
expect(await index.doc.index["data:body"].length).to.equal(0);
}
});
it("Should have been indexed properly (Worker)", async function(){
@@ -128,8 +132,11 @@ describe("Index Multi-Field Documents (ES6)", function(){
await index.add(data);
expect(index.doc.index["data:title"].length).to.equal(3);
expect(index.doc.index["data:body"].length).to.equal(3);
if(env === ""){
expect(index.doc.index["data:title"].length).to.equal(3);
expect(index.doc.index["data:body"].length).to.equal(3);
}
expect(await index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
@@ -163,7 +170,10 @@ describe("Index Multi-Field Documents (ES6)", function(){
await index.remove(update);
expect(await index.doc.index["data:title"].length).to.equal(0);
expect(await index.doc.index["data:body"].length).to.equal(0);
if(env === ""){
expect(await index.doc.index["data:title"].length).to.equal(0);
expect(await index.doc.index["data:body"].length).to.equal(0);
}
});
});