added test for dot-notation in matchesKeyInQuery

This commit is contained in:
Henrik Malmberg
2017-11-01 11:17:10 +01:00
committed by Arthur Cinader
parent 741f869140
commit 4ceff38811

View File

@@ -3206,4 +3206,46 @@ describe('Parse.Query testing', () => {
.then(() => q.find({ useMasterKey: true }))
.then(done.fail, done);
});
it('should match complex structure with dot notation when using matchesKeyInQuery', function(done) {
const group1 = new Parse.Object('Group', {
name: 'Group #1'
});
const group2 = new Parse.Object('Group', {
name: 'Group #2'
});
Parse.Object.saveAll([group1, group2])
.then(() => {
const role1 = new Parse.Object('Role', {
name: 'Role #1',
type: 'x',
belongsTo: group1
});
const role2 = new Parse.Object('Role', {
name: 'Role #2',
type: 'y',
belongsTo: group1
});
return Parse.Object.saveAll([role1, role2]);
})
.then(() => {
const rolesOfTypeX = new Parse.Query('Role');
rolesOfTypeX.equalTo('type', 'x');
const groupsWithRoleX = new Parse.Query('Group');
groupsWithRoleX.matchesKeyInQuery('objectId', 'belongsTo.objectId', rolesOfTypeX);
groupsWithRoleX.find(expectSuccess({
success: function(results) {
equal(results.length, 1);
equal(results[0].get('name'), group1.get('name'));
done();
}
}))
})
});
});