Skip to content

Commit 4ceff38

Browse files
bohemimaacinader
authored andcommitted
added test for dot-notation in matchesKeyInQuery
1 parent 741f869 commit 4ceff38

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

spec/ParseQuery.spec.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,4 +3206,46 @@ describe('Parse.Query testing', () => {
32063206
.then(() => q.find({ useMasterKey: true }))
32073207
.then(done.fail, done);
32083208
});
3209+
3210+
it('should match complex structure with dot notation when using matchesKeyInQuery', function(done) {
3211+
const group1 = new Parse.Object('Group', {
3212+
name: 'Group #1'
3213+
});
3214+
3215+
const group2 = new Parse.Object('Group', {
3216+
name: 'Group #2'
3217+
});
3218+
3219+
Parse.Object.saveAll([group1, group2])
3220+
.then(() => {
3221+
const role1 = new Parse.Object('Role', {
3222+
name: 'Role #1',
3223+
type: 'x',
3224+
belongsTo: group1
3225+
});
3226+
3227+
const role2 = new Parse.Object('Role', {
3228+
name: 'Role #2',
3229+
type: 'y',
3230+
belongsTo: group1
3231+
});
3232+
3233+
return Parse.Object.saveAll([role1, role2]);
3234+
})
3235+
.then(() => {
3236+
const rolesOfTypeX = new Parse.Query('Role');
3237+
rolesOfTypeX.equalTo('type', 'x');
3238+
3239+
const groupsWithRoleX = new Parse.Query('Group');
3240+
groupsWithRoleX.matchesKeyInQuery('objectId', 'belongsTo.objectId', rolesOfTypeX);
3241+
3242+
groupsWithRoleX.find(expectSuccess({
3243+
success: function(results) {
3244+
equal(results.length, 1);
3245+
equal(results[0].get('name'), group1.get('name'));
3246+
done();
3247+
}
3248+
}))
3249+
})
3250+
});
32093251
});

0 commit comments

Comments
 (0)