mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-01 18:03:56 +02:00
remove broken test framework (will come back soon)
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var port = process.argv[2];
|
||||
|
||||
if(!port){
|
||||
|
||||
if(/^win/.test(process.platform)){
|
||||
|
||||
port = 80;
|
||||
}
|
||||
else{
|
||||
|
||||
port = 8080;
|
||||
}
|
||||
}
|
||||
|
||||
var ws = require('web-servo');
|
||||
|
||||
ws.config({
|
||||
|
||||
"server": {
|
||||
"port": port,
|
||||
"dir": "/",
|
||||
"exitOnError": false,
|
||||
"ssl": {
|
||||
"enabled": false,
|
||||
"key": "",
|
||||
"cert": ""
|
||||
}
|
||||
},
|
||||
"page": {
|
||||
"default": "index.html"
|
||||
},
|
||||
"methods": {
|
||||
"allowed": [
|
||||
"OPTIONS",
|
||||
"GET",
|
||||
"POST",
|
||||
"HEAD",
|
||||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE"
|
||||
//"COPY",
|
||||
//"LINK",
|
||||
//"UNLINK",
|
||||
//"TRACE",
|
||||
//"CONNECT"
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
//ws.setConfigVar('server.port', port);
|
||||
ws.silent().start();
|
||||
|
||||
console.log("-----------------------------------------------------");
|
||||
console.log("Hit CTRL-C to stop the server...");
|
@@ -1,83 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Test: Export / Import</title>
|
||||
<script src="../flexsearch.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
var config = {
|
||||
encode: "icase",
|
||||
tokenize: "strict",
|
||||
threshold: 1,
|
||||
resolution: 3,
|
||||
depth: 1,
|
||||
doc: {
|
||||
id: "id",
|
||||
field: "title",
|
||||
store: "body:content"
|
||||
}
|
||||
};
|
||||
|
||||
var index = new FlexSearch(config);
|
||||
|
||||
var docs = [{
|
||||
id: 1,
|
||||
title: "Title 2",
|
||||
body: {content: "foobar"}
|
||||
},{
|
||||
id: 0,
|
||||
title: "Title 1",
|
||||
body: {content: "foo"}
|
||||
},{
|
||||
id: 2,
|
||||
title: "Title 3",
|
||||
body: {content: "bar"}
|
||||
}];
|
||||
|
||||
index.add(docs);
|
||||
|
||||
console.log(index.search("title"));
|
||||
|
||||
var idx = index.export({
|
||||
doc: false,
|
||||
index: true,
|
||||
serialize: false
|
||||
});
|
||||
|
||||
var doc = index.export({
|
||||
doc: true,
|
||||
index: false,
|
||||
serialize: false
|
||||
});
|
||||
|
||||
index = new FlexSearch(config);
|
||||
|
||||
index.import(idx, {
|
||||
doc: false,
|
||||
index: true,
|
||||
serialize: false
|
||||
});
|
||||
|
||||
index.import(doc, {
|
||||
doc: true,
|
||||
index: false,
|
||||
serialize: false
|
||||
});
|
||||
|
||||
console.log(index.search("title"));
|
||||
|
||||
index = new FlexSearch(config);
|
||||
|
||||
index.import(idx, {
|
||||
doc: docs,
|
||||
index: true,
|
||||
serialize: false
|
||||
});
|
||||
|
||||
console.log(index.search("title"));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,54 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Tests</title>
|
||||
<link rel="stylesheet" media="all" href="node_modules/mocha/mocha.css">
|
||||
<style>
|
||||
body{
|
||||
background-color: #151515;
|
||||
filter: invert(1);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"><p><a href=".">Index</a></p></div>
|
||||
<div id="messages"></div>
|
||||
<div id="fixtures"></div>
|
||||
<script>
|
||||
var param = window.location.search.substr(1);
|
||||
if(param === "coverage"){
|
||||
document.write('<script type="text/javascript" src="dist/dist/flexsearch.pre.js"><\/script>');
|
||||
}
|
||||
else if(param === "es5" || param === "light" || param === "min"){
|
||||
document.write('<script type="text/javascript" src="../dist/flexsearch.' + param + '.js"><\/script>');
|
||||
}
|
||||
else{
|
||||
document.write('<script type="text/javascript" src="dist/flexsearch.pre.js"><\/script>');
|
||||
}
|
||||
</script>
|
||||
<script src="node_modules/mocha/mocha.js"></script>
|
||||
<script src="node_modules/chai/chai.js"></script>
|
||||
<!--<script src="../node_modules/mocha-phantomjs-core/browser-shim.js"></script>-->
|
||||
<script>
|
||||
window.initMochaPhantomJS && initMochaPhantomJS();
|
||||
mocha.ui('bdd');
|
||||
mocha.reporter('html');
|
||||
mocha.setup('bdd');
|
||||
var expect = chai.expect;
|
||||
var env = "min";
|
||||
</script>
|
||||
<script src="test.js"></script>
|
||||
<!--<script src="test.es6.js"></script>-->
|
||||
<script>
|
||||
if(window.mochaPhantomJS) {
|
||||
|
||||
mochaPhantomJS.run();
|
||||
}
|
||||
else{
|
||||
|
||||
mocha.run();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,21 +0,0 @@
|
||||
const libCoverage = require('istanbul-lib-coverage');
|
||||
const { createReporter } = require('istanbul-api');
|
||||
|
||||
const coverage_1 = require('./.nyc_output/coverage.json');
|
||||
const coverage_2 = require('./.nyc_output/coverage2.json');
|
||||
|
||||
const normalizeJestCoverage = (obj) => {
|
||||
const result = obj;
|
||||
Object.entries(result).forEach(([k, v]) => {
|
||||
if (v.data) result[k] = v.data;
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
const map = libCoverage.createCoverageMap();
|
||||
map.merge(normalizeJestCoverage(coverage_1));
|
||||
map.merge(normalizeJestCoverage(coverage_2));
|
||||
|
||||
const reporter = createReporter();
|
||||
reporter.addAll(['html', 'json', 'lcov', 'text']);
|
||||
reporter.write(map);
|
@@ -1,50 +0,0 @@
|
||||
{
|
||||
"public": false,
|
||||
"preferGlobal": false,
|
||||
"scripts": {
|
||||
|
||||
|
||||
"test:production": "mocha --timeout=3000 test --exit",
|
||||
"test:light": "mocha --timeout=3000 test/ --exit",
|
||||
"test:develop": "mocha --timeout=3000 --exit",
|
||||
"test:browser": "nyc instrument ./dist/flexsearch.pre.js ./dist/ && nyc --reporter=html --reporter=text --cache true mocha-headless-chrome -f index.html?coverage -c .nyc_output/coverage.json && mocha-headless-chrome -f polyfill.html?coverage -c .nyc_output/coverage2.json",
|
||||
"test:polyfill": "nyc --reporter=html --reporter=text --cache true mocha-headless-chrome -f polyfill.html?coverage -c .nyc_output/coverage2.json",
|
||||
"test:es5": "mocha-phantomjs index.html",
|
||||
|
||||
|
||||
|
||||
"test": "npm run test:es5 && npm run test:browser && node ./merge-coverage.js",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"server": "node server.js"
|
||||
},
|
||||
"nyc": {
|
||||
"per-file": true,
|
||||
"all": true,
|
||||
"exclude-after-remap": false,
|
||||
"include": [
|
||||
"dist/flexsearch.pre.js"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"src/",
|
||||
"task/",
|
||||
"server/",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"readme": "README.md",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"codacy-coverage": "^3.4.0",
|
||||
"coveralls": "^3.0.7",
|
||||
"istanbul-api": "^2.1.6",
|
||||
"mocha": "^6.2.0",
|
||||
"mocha-headless-chrome": "^2.0.3",
|
||||
"mocha-lcov-reporter": "^1.3.0",
|
||||
"mocha-phantomjs": "^4.1.0",
|
||||
"nyc": "^14.1.1",
|
||||
"web-servo": "^0.5.1"
|
||||
}
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Tests</title>
|
||||
<link rel="stylesheet" media="all" href="node_modules/mocha/mocha.css">
|
||||
<style>
|
||||
body{
|
||||
background-color: #151515;
|
||||
filter: invert(1);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"><p><a href=".">Index</a></p></div>
|
||||
<div id="messages"></div>
|
||||
<div id="fixtures"></div>
|
||||
<script>
|
||||
var param = window.location.search.substr(1);
|
||||
if(param === "coverage"){
|
||||
Object.assign = null;
|
||||
Object.values = null;
|
||||
window["requestAnimationFrame"] = null;
|
||||
window["cancelAnimationFrame"] = null;
|
||||
window["Promise"] = null;
|
||||
window["_Proxy"] = window["Proxy"];
|
||||
window["Proxy"] = null;
|
||||
document.write('<script type="text/javascript" src="dist/dist/flexsearch.pre.js"><\/script>');
|
||||
}
|
||||
else if(param === "es5" || param === "light" || param === "min"){
|
||||
document.write('<script type="text/javascript" src="../dist/flexsearch.' + param + '.js"><\/script>');
|
||||
}
|
||||
else{
|
||||
document.write('<script type="text/javascript" src="dist/flexsearch.pre.js"><\/script>');
|
||||
}
|
||||
</script>
|
||||
<script>window["Proxy"] = window["_Proxy"];</script>
|
||||
<script src="node_modules/mocha/mocha.js"></script>
|
||||
<script src="node_modules/chai/chai.js"></script>
|
||||
<script>
|
||||
window.initMochaPhantomJS && initMochaPhantomJS();
|
||||
mocha.ui('bdd');
|
||||
mocha.reporter('html');
|
||||
mocha.setup('bdd');
|
||||
var expect = chai.expect;
|
||||
var env = "min";
|
||||
</script>
|
||||
<script src="test.js"></script>
|
||||
<!--<script src="test.es6.js"></script>-->
|
||||
<script>
|
||||
if(window.mochaPhantomJS) {
|
||||
|
||||
mochaPhantomJS.run();
|
||||
}
|
||||
else{
|
||||
|
||||
mocha.run();
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var port = process.argv[2];
|
||||
|
||||
if(!port){
|
||||
|
||||
if(/^win/.test(process.platform)){
|
||||
|
||||
port = 80;
|
||||
}
|
||||
else{
|
||||
|
||||
port = 8080;
|
||||
}
|
||||
}
|
||||
|
||||
var ws = require('web-servo');
|
||||
|
||||
ws.config({
|
||||
|
||||
"server": {
|
||||
"port": port,
|
||||
"dir": "/",
|
||||
"exitOnError": false,
|
||||
"ssl": {
|
||||
"enabled": false,
|
||||
"key": "",
|
||||
"cert": ""
|
||||
}
|
||||
},
|
||||
"page": {
|
||||
"default": "index.html"
|
||||
},
|
||||
"methods": {
|
||||
"allowed": [
|
||||
"OPTIONS",
|
||||
"GET",
|
||||
"POST",
|
||||
"HEAD",
|
||||
"PUT",
|
||||
"PATCH",
|
||||
"DELETE"
|
||||
//"COPY",
|
||||
//"LINK",
|
||||
//"UNLINK",
|
||||
//"TRACE",
|
||||
//"CONNECT"
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
//ws.setConfigVar('server.port', port);
|
||||
ws.silent().start();
|
||||
|
||||
console.log("-----------------------------------------------------");
|
||||
console.log("Hit CTRL-C to stop the server...");
|
179
test/test.es6.js
179
test/test.es6.js
@@ -1,179 +0,0 @@
|
||||
if(typeof module !== "undefined"){
|
||||
|
||||
var env = "pre";
|
||||
var expect = require("chai").expect;
|
||||
var FlexSearch = require("../" + (env ? "dist/": "") + "flexsearch" + (env ? "." + env : "") + ".js");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Multi-Field Documents
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
describe("Index Multi-Field Documents (ES6)", function(){
|
||||
|
||||
var data = [{
|
||||
|
||||
id: 2,
|
||||
data:{
|
||||
title: "Title 3",
|
||||
body: "Body 3"
|
||||
}
|
||||
},{
|
||||
id: 1,
|
||||
data:{
|
||||
title: "Title 2",
|
||||
body: "Body 2"
|
||||
}
|
||||
},{
|
||||
id: 0,
|
||||
data:{
|
||||
title: "Title 1",
|
||||
body: "Body 1"
|
||||
}
|
||||
}];
|
||||
|
||||
var update = [{
|
||||
|
||||
id: 0,
|
||||
data:{
|
||||
title: "Foo 1",
|
||||
body: "Bar 1"
|
||||
}
|
||||
},{
|
||||
id: 1,
|
||||
data:{
|
||||
title: "Foo 2",
|
||||
body: "Bar 2"
|
||||
}
|
||||
},{
|
||||
id: 2,
|
||||
data:{
|
||||
title: "Foo 3",
|
||||
body: "Bar 3"
|
||||
}
|
||||
}];
|
||||
|
||||
it("Should have been indexed properly (Async)", async function(){
|
||||
|
||||
var index = new FlexSearch({
|
||||
|
||||
async: true,
|
||||
doc: {
|
||||
id: "id",
|
||||
field: [
|
||||
"data:title",
|
||||
"data:body"
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
await index.add(data);
|
||||
|
||||
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);
|
||||
|
||||
expect(await index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
|
||||
expect(await index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
|
||||
|
||||
expect(await index.search({field: ["data:title", "data:body"], query: "body", bool: "or"})).to.have.members(data);
|
||||
expect(await index.search({field: ["data:body", "data:title"], query: "title", bool: "or"})).to.have.members(data);
|
||||
|
||||
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);
|
||||
|
||||
expect(await index.search({query: "body", bool: "or"})).to.have.members(data);
|
||||
expect(await index.search("title", {bool: "or"})).to.have.members(data);
|
||||
|
||||
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);
|
||||
|
||||
await index.update(update);
|
||||
|
||||
expect(await index.search("foo", {bool: "or"})).not.to.have.members(data);
|
||||
expect(await index.search("bar", {bool: "or"})).not.to.have.members(data);
|
||||
expect(await index.search("foo", {bool: "or"})).to.have.members(update);
|
||||
expect(await index.search("bar", {bool: "or"})).to.have.members(update);
|
||||
|
||||
expect(await index.search("foo", {field: "data:title"})).not.to.have.members(data);
|
||||
expect(await index.search("bar", {field: "data:body"})).not.to.have.members(data);
|
||||
expect(await index.search("foo", {field: "data:title"})).to.have.members(update);
|
||||
expect(await index.search("bar", {field: "data:body"})).to.have.members(update);
|
||||
|
||||
await index.remove(update);
|
||||
|
||||
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(){
|
||||
|
||||
var index = new FlexSearch({
|
||||
|
||||
worker: 4,
|
||||
async: true,
|
||||
doc: {
|
||||
|
||||
id: "id",
|
||||
field: [
|
||||
"data:title",
|
||||
"data:body"
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
await index.add(data);
|
||||
|
||||
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);
|
||||
|
||||
expect(await index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
|
||||
expect(await index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
|
||||
|
||||
expect(await index.search({field: ["data:title", "data:body"], query: "body", bool: "or"})).to.have.members(data);
|
||||
expect(await index.search({field: ["data:body", "data:title"], query: "title", bool: "or"})).to.have.members(data);
|
||||
|
||||
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);
|
||||
|
||||
expect(await index.search({query: "body", bool: "or"})).to.have.members(data);
|
||||
expect(await index.search("title", {bool: "or"})).to.have.members(data);
|
||||
|
||||
expect(await index.search({query: "body", field: "data:body"})).to.have.members(data);
|
||||
expect(await index.search("title", {field: "data:title"})).to.have.members(data);
|
||||
|
||||
await index.update(update);
|
||||
|
||||
expect(await index.search("foo", {bool: "or"})).not.to.have.members(data);
|
||||
expect(await index.search("bar", {bool: "or"})).not.to.have.members(data);
|
||||
expect(await index.search("foo", {bool: "or"})).to.have.members(update);
|
||||
expect(await index.search("bar", {bool: "or"})).to.have.members(update);
|
||||
|
||||
expect(await index.search("foo", {field: "data:title"})).not.to.have.members(data);
|
||||
expect(await index.search("bar", {field: "data:body"})).not.to.have.members(data);
|
||||
expect(await index.search("foo", {field: "data:title"})).to.have.members(update);
|
||||
expect(await index.search("bar", {field: "data:body"})).to.have.members(update);
|
||||
|
||||
await index.remove(update);
|
||||
|
||||
if(env === ""){
|
||||
|
||||
expect(await index.doc.index["data:title"].length).to.equal(0);
|
||||
expect(await index.doc.index["data:body"].length).to.equal(0);
|
||||
}
|
||||
});
|
||||
});
|
2968
test/test.js
2968
test/test.js
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user