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:
@@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user