Skip to content

Commit

Permalink
add nested relational and query test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingtous committed Sep 24, 2021
1 parent 0fa8f5e commit c262c77
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3458,4 +3458,23 @@ describe('sendEmail', () => {
'Failed to send email because no mail adapter is configured for Parse Server.'
);
});

it('should have object found with nested relational data query', async () => {
const obj1 = Parse.Object.extend('TestObject');
const obj2 = Parse.Object.extend('TestObject2');
let item2 = new obj2();
item2 = await item2.save();
let item1 = new obj1();
const relation = item1.relation('rel');
relation.add(item2);
item1 = await item1.save();
Parse.Cloud.beforeFind('TestObject', req => {
const additionalQ = new Parse.Query('TestObject');
additionalQ.equalTo('rel', item2);
return Parse.Query.and(req.query, additionalQ);
});
const q = new Parse.Query('TestObject');
const res = await q.first();
expect(res).toBeDefined();
});
});

0 comments on commit c262c77

Please sign in to comment.