Skip to content

Commit

Permalink
⚡ regression tests for #1349
Browse files Browse the repository at this point in the history
  • Loading branch information
System Administrator authored and flovilmart committed Apr 3, 2016
1 parent f99b558 commit b6d15d7
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions spec/ParseQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,95 @@ describe('Parse.Query testing', () => {
});
});

it("notEqualTo with Relation is working", function(done) {
var user = new Parse.User();
user.setPassword("asdf");
user.setUsername("zxcv");

var user1 = new Parse.User();
user1.setPassword("asdf");
user1.setUsername("qwerty");

var user2 = new Parse.User();
user2.setPassword("asdf");
user2.setUsername("asdf");

var Cake = Parse.Object.extend("Cake");
var cake1 = new Cake();
var cake2 = new Cake();
var cake3 = new Cake();


user.signUp().then(function(){
return user1.signUp();
}).then(function(){
return user2.signUp();
}).then(function(){
var relLike1 = cake1.relation("amateur");
relLike1.add(user);
relLike1.add(user1);

var relDislike1 = cake1.relation("hater");
relLike1.add(user2);

return cake1.save();
}).then(function(){
var rellike2 = cake2.relation("amateur");
rellike2.add(user);
rellike2.add(user1);

var relDislike2 = cake2.relation("hater");
rellike2.add(user2);

return cake2.save();
}).then(function(){
var rellike3 = cake3.relation("amateur");
rellike3.add(user);

var relDislike3 = cake3.relation("hater");
rellike3.add(user1);
rellike3.add(user2);

return cake3.save();
}).then(function(){
var query = new Parse.Query(Cake);
// User2 likes nothing so we should receive 0
query.equalTo("liker", user2);
return query.find().then(function(results){
equal(results.length, 0);
});
}).then(function(){
var query = new Parse.Query(Cake);
// User1 likes two of three cakes
query.equalTo("liker", user1);
return query.find().then(function(results){
// This test fails on 2.2.4
// It should return 2 -> cake 1 and cake 2
equal(results.length, 2);
});
}).then(function(){
var query = new Parse.Query(Cake);
// We want to know which cake the user1 is not appreciating -> cake3
query.notEqualTo("liker", user1);
return query.find().then(function(results){
// This test fails on 2.2.4
// Should return 1 -> the cake 3
equal(results.length, 1);
});
}).then(function(){
var query = new Parse.Query(Cake);
// User2 is a hater of everything so we should receive 0
query.notEqualTo("hater", user2);
return query.find().then(function(results){
// This test fails on 2.2.4
equal(results.length, 0);
});
}).then(function(){
done();
})

});

it("query with limit", function(done) {
var baz = new TestObject({ foo: 'baz' });
var qux = new TestObject({ foo: 'qux' });
Expand Down

0 comments on commit b6d15d7

Please sign in to comment.