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
e3d3b88f
Commit
e3d3b88f
authored
Aug 06, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
complex queries tests added
parent
17dfeaa4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
149 additions
and
131 deletions
+149
-131
test/jiotests.js
test/jiotests.js
+0
-129
test/jiotests_withoutrequirejs.html
test/jiotests_withoutrequirejs.html
+3
-1
test/queries/tests.js
test/queries/tests.js
+144
-0
test/tests.require.js
test/tests.require.js
+2
-1
No files found.
test/jiotests.js
View file @
e3d3b88f
...
...
@@ -272,135 +272,6 @@ 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 Dummy Storages
"
);
test
(
"
All requests ok
"
,
function
()
{
...
...
test/jiotests_withoutrequirejs.html
View file @
e3d3b88f
...
...
@@ -11,11 +11,13 @@
<script
src=
"../lib/sinon/sinon.js"
></script>
<script
src=
"../lib/sinon/sinon-qunit.js"
></script>
<script
src=
"../complex_queries.js"
></script>
<script
src=
"./queries/tests.js"
></script>
<script
src=
"../lib/md5/md5.js"
></script>
<script
src=
"../jio.js"
></script>
<script
src=
"./jio/tests.js"
></script>
<script
src=
"../complex_queries.js"
></script>
<script
src=
"../src/jio.storage/localstorage.js"
></script>
<script
src=
"./jio.storage/localstorage.tests.js"
></script>
</body>
...
...
test/queries/tests.js
0 → 100644
View file @
e3d3b88f
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, complex_queries, window, test, ok, deepEqual, sinon */
// define([module_name], [dependencies], module);
(
function
(
dependencies
,
module
)
{
"
use strict
"
;
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
return
define
(
dependencies
,
module
);
}
module
(
complex_queries
);
}([
'
complex_queries
'
],
function
(
complex_queries
)
{
"
use strict
"
;
module
(
'
Complex Queries
'
);
// XXX test documentation
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
'
);
});
}));
test/tests.require.js
View file @
e3d3b88f
...
...
@@ -8,6 +8,7 @@
"
paths
"
:
{
"
md5
"
:
"
../lib/md5/md5
"
,
"
complex_queries
"
:
"
../complex_queries
"
,
"
complex_queries_tests
"
:
"
queries/tests
"
,
"
jio
"
:
"
../jio
"
,
"
jio_tests
"
:
"
jio/tests
"
,
"
localstorage
"
:
"
../src/jio.storage/localstorage
"
,
...
...
@@ -19,7 +20,6 @@
},
"
shim
"
:
{
"
md5
"
:
{
"
exports
"
:
"
hex_md5
"
},
"
localstorage
"
:
[
"
jio
"
,
"
complex_queries
"
],
"
sinon
"
:
[
"
qunit
"
],
"
sinon_qunit
"
:
[
"
sinon
"
]
...
...
@@ -28,6 +28,7 @@
require
([
"
sinon_qunit
"
,
"
complex_queries_tests
"
,
"
jio_tests
"
,
"
localstorage_tests
"
]);
...
...
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