refactor: test moved to correct test group (#7717)

This commit is contained in:
Corey
2021-11-25 10:16:46 -08:00
committed by GitHub
parent 260290409e
commit c789f6c979
2 changed files with 21 additions and 21 deletions

View File

@@ -1999,6 +1999,25 @@ describe('beforeFind hooks', () => {
}); });
}); });
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.id).toEqual(item1.id);
});
it('should use the modified exclude query', async () => { it('should use the modified exclude query', async () => {
Parse.Cloud.beforeFind('MyObject', req => { Parse.Cloud.beforeFind('MyObject', req => {
const q = req.query; const q = req.query;
@@ -3516,23 +3535,4 @@ describe('sendEmail', () => {
'Failed to send email because no mail adapter is configured for Parse Server.' '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.id).toEqual(item1.id);
});
}); });

View File

@@ -972,9 +972,9 @@ class DatabaseController {
}); });
} }
if (query['$and']) { if (query['$and']) {
const ors = query['$and']; const ands = query['$and'];
return Promise.all( return Promise.all(
ors.map((aQuery, index) => { ands.map((aQuery, index) => {
return this.reduceInRelation(className, aQuery, schema).then(aQuery => { return this.reduceInRelation(className, aQuery, schema).then(aQuery => {
query['$and'][index] = aQuery; query['$and'][index] = aQuery;
}); });