Skip to content

Commit 40d0421

Browse files
committed
Added AV.Query.and test
1 parent ae10c71 commit 40d0421

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

tests/query.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ describe("Counts",function(){
288288
})
289289

290290
describe("Compound Query",function(){
291-
it("satisfy on of the conditions",function(done){
291+
it("satisfy on 'or' conditions",function(done){
292292
var lotsOfWins = new AV.Query("GameScore");
293293
lotsOfWins.greaterThan("score",150);
294294

@@ -298,7 +298,31 @@ describe("Compound Query",function(){
298298
var mainQuery = AV.Query.or(lotsOfWins, fewWins);
299299
mainQuery.find({
300300
success: function(results) {
301-
done();
301+
results.forEach(function(gs){
302+
expect(gs.get('score') > 150 || gs.get('cheatMode')).to.be.ok();
303+
});
304+
done();
305+
// results contains a list of players that either have won a lot of games or won only a few games.
306+
},
307+
error: function(error) {
308+
// There was an error.
309+
}
310+
});
311+
});
312+
it("satisfy on 'and' conditions",function(done){
313+
var lotsOfWins = new AV.Query("GameScore");
314+
lotsOfWins.greaterThan("score",150);
315+
316+
var fewWins = new AV.Query("GameScore");
317+
fewWins.equalTo("cheatMode",true);
318+
319+
var mainQuery = AV.Query.and(lotsOfWins, fewWins);
320+
mainQuery.find({
321+
success: function(results) {
322+
results.forEach(function(gs){
323+
expect(gs.get('score') > 150 && gs.get('cheatMode')).to.be.ok();
324+
});
325+
done();
302326
// results contains a list of players that either have won a lot of games or won only a few games.
303327
},
304328
error: function(error) {

0 commit comments

Comments
 (0)