Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
jio-main
Commits
55a305d5
Commit
55a305d5
authored
Jul 16, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests added for complex queries
parent
3cfc4665
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
129 additions
and
0 deletions
+129
-0
test/jiotests.js
test/jiotests.js
+129
-0
No files found.
test/jiotests.js
View file @
55a305d5
...
...
@@ -272,6 +272,135 @@ isUuid = function (uuid) {
false
:
true
;
};
//// QUnit Tests ////
module
(
'
Complex Queries
'
);
test
(
'
Empty Query
'
,
function
()
{
var
doc_list
=
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
[
"
b
"
,
"
c
"
]}
];
complex_queries
.
QueryFactory
.
create
(
''
).
exec
(
doc_list
);
deepEqual
(
doc_list
,
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
[
"
b
"
,
"
c
"
]}
],
'
Nothing done on the list
'
);
});
test
(
'
Simple Query
'
,
function
()
{
var
doc_list
=
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
[
"
b
"
,
"
c
"
]}
];
complex_queries
.
QueryFactory
.
create
(
'
identifier: "a"
'
).
exec
(
doc_list
);
deepEqual
(
doc_list
,
[
{
"
identifier
"
:
"
a
"
},
],
'
Document with several identifier should be removed
'
);
doc_list
=
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
[
"
a
"
,
"
b
"
]}
];
complex_queries
.
QueryFactory
.
create
(
'
identifier: "a"
'
).
exec
(
doc_list
);
deepEqual
(
doc_list
,
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
[
"
a
"
,
"
b
"
]}
],
'
Document with several identifier should be kept
'
);
});
test
(
'
Complex Query
'
,
function
()
{
var
doc_list
=
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
[
"
b
"
,
"
c
"
]}
];
complex_queries
.
QueryFactory
.
create
(
'
identifier: "b" AND identifier: "c"
'
).
exec
(
doc_list
);
deepEqual
(
doc_list
,
[
{
"
identifier
"
:
[
"
b
"
,
"
c
"
]}
],
'
Document with only one identifier should be removed
'
);
doc_list
=
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
[
"
b
"
,
"
c
"
]}
];
complex_queries
.
QueryFactory
.
create
(
'
identifier: "a" OR identifier: "c"
'
).
exec
(
doc_list
);
deepEqual
(
doc_list
,
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
[
"
b
"
,
"
c
"
]}
],
'
All document matches
'
);
doc_list
=
[
{
"
identifier
"
:
"
a
"
,
"
title
"
:
"
o
"
},
{
"
identifier
"
:
[
"
b
"
,
"
c
"
]}
];
complex_queries
.
QueryFactory
.
create
(
'
(identifier: "a" OR identifier: "b") AND title: "o"
'
).
exec
(
doc_list
);
deepEqual
(
doc_list
,
[
{
"
identifier
"
:
"
a
"
,
"
title
"
:
"
o
"
}
],
'
Only first document should be kept
'
);
});
test
(
'
Wildcard Character
'
,
function
()
{
var
doc_list
=
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
"
a%
"
},
{
"
identifier
"
:
[
"
ab
"
,
"
b
"
]}
];
complex_queries
.
QueryFactory
.
create
(
'
identifier: "a%"
'
).
exec
(
doc_list
,
{
// "wildcard_character": "%" // default
});
deepEqual
(
doc_list
,
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
"
a%
"
},
{
"
identifier
"
:
[
"
ab
"
,
"
b
"
]}
],
'
All documents should be kept
'
);
doc_list
=
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
"
a%
"
},
{
"
identifier
"
:
[
"
ab
"
,
"
b
"
]}
];
complex_queries
.
QueryFactory
.
create
(
'
identifier: "a%"
'
).
exec
(
doc_list
,
{
"
wildcard_character
"
:
null
});
deepEqual
(
doc_list
,
[
{
"
identifier
"
:
"
a%
"
}
],
'
Document "a%" should be kept
'
);
doc_list
=
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
"
a%
"
},
{
"
identifier
"
:
[
"
ab
"
,
"
b
"
]}
];
complex_queries
.
QueryFactory
.
create
(
'
identifier: "b"
'
).
exec
(
doc_list
,
{
"
wildcard_character
"
:
"
b
"
});
deepEqual
(
doc_list
,
[
{
"
identifier
"
:
"
a
"
},
{
"
identifier
"
:
"
a%
"
},
{
"
identifier
"
:
[
"
ab
"
,
"
b
"
]}
],
'
All documents should be kept
'
);
});
test
(
"
Additional Filters
"
,
function
()
{
var
doc_list
=
[
{
"
identifier
"
:
"
b
"
,
"
title
"
:
"
e
"
},
{
"
identifier
"
:
"
a
"
,
"
title
"
:
"
f
"
},
{
"
identifier
"
:
"
b
"
,
"
title
"
:
"
d
"
}
];
complex_queries
.
QueryFactory
.
create
(
''
).
exec
(
doc_list
,
{
"
select_list
"
:
[
"
title
"
],
"
limit
"
:
[
2
,
1
],
"
sort_on
"
:
[[
"
identifier
"
,
"
ascending
"
],
[
"
title
"
,
"
descending
"
]]
});
deepEqual
(
doc_list
,
[
{
"
title
"
:
"
d
"
}
],
'
The first document should be kept
'
);
});
module
(
'
Jio Global tests
'
);
test
(
"
Jio simple methods
"
,
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment