Commit 0a1e517d authored by Romain Courteaud's avatar Romain Courteaud

Queries: ensure that default search string works with non ascii character

parent 230d0323
/*jslint indent: 2, maxlen: 80, nomen: true */ /*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, exports, require, module, jIO, window, test, ok, /*global define, exports, require, module, jIO, window, test, ok,
deepEqual, stop, start */ deepEqual, stop, start, expect */
// define([module_name], [dependencies], module); // define([module_name], [dependencies], module);
(function (dependencies, module) { (function (dependencies, module) {
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
{"identifier": ["b", "c"]} {"identifier": ["b", "c"]}
]; ];
stop(); stop();
expect(1);
jIO.QueryFactory.create('').exec(doc_list). jIO.QueryFactory.create('').exec(doc_list).
then(function (doc_list) { then(function (doc_list) {
deepEqual(doc_list, [ deepEqual(doc_list, [
...@@ -39,6 +40,7 @@ ...@@ -39,6 +40,7 @@
{"identifier": ["b", "c"]} {"identifier": ["b", "c"]}
]; ];
stop(); stop();
expect(2);
jIO.QueryFactory.create('identifier: "a"').exec(doc_list). jIO.QueryFactory.create('identifier: "a"').exec(doc_list).
then(function (doc_list) { then(function (doc_list) {
deepEqual(doc_list, [ deepEqual(doc_list, [
...@@ -66,6 +68,7 @@ ...@@ -66,6 +68,7 @@
{"identifier": ["b", "c"]} {"identifier": ["b", "c"]}
]; ];
stop(); stop();
expect(3);
jIO.QueryFactory.create( jIO.QueryFactory.create(
'identifier: "b" AND identifier: "c"' 'identifier: "b" AND identifier: "c"'
).exec(doc_list).then(function (doc_list) { ).exec(doc_list).then(function (doc_list) {
...@@ -108,6 +111,7 @@ ...@@ -108,6 +111,7 @@
{"identifier": ["a", "b"]} {"identifier": ["a", "b"]}
]; ];
stop(); stop();
expect(4);
jIO.QueryFactory.create( jIO.QueryFactory.create(
'(identifier: "%测试一%" OR identifier: "%测试二%") AND identifier: "%测试四%"' '(identifier: "%测试一%" OR identifier: "%测试二%") AND identifier: "%测试四%"'
) )
...@@ -145,6 +149,15 @@ ...@@ -145,6 +149,15 @@
deepEqual(doc_list, [ deepEqual(doc_list, [
{"identifier": "测试一", "title": "标题"} {"identifier": "测试一", "title": "标题"}
], 'Only second document should be kept'); ], 'Only second document should be kept');
return jIO.QueryFactory.create('测试')
.exec(doc_list);
})
.then(function (doc_list) {
deepEqual(doc_list, [], 'No document should be kept');
})
.fail(function (error) {
ok(false, error);
}).always(start); }).always(start);
}); });
...@@ -156,6 +169,7 @@ ...@@ -156,6 +169,7 @@
{"identifier": ["ab", "b"]} {"identifier": ["ab", "b"]}
]; ];
stop(); stop();
expect(4);
jIO.QueryFactory.create('identifier: "a%"').exec( jIO.QueryFactory.create('identifier: "a%"').exec(
doc_list doc_list
).then(function (doc_list) { ).then(function (doc_list) {
...@@ -222,6 +236,7 @@ ...@@ -222,6 +236,7 @@
{"identifier": "b", "title": "d"} {"identifier": "b", "title": "d"}
]; ];
stop(); stop();
expect(1);
jIO.QueryFactory.create('').exec(doc_list, { jIO.QueryFactory.create('').exec(doc_list, {
"select_list": ["title"], "select_list": ["title"],
"limit": [2, 1], "limit": [2, 1],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment