Skip to content

Commit e2fbee4

Browse files
authored
Failing test case for CloudCode.spec.js
Signed-off-by: Rikard Teodorsson <[email protected]>
1 parent 9b9c3a4 commit e2fbee4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

spec/CloudCode.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,6 +2510,25 @@ describe('beforeFind hooks', () => {
25102510
expect(res2.get('pointerFieldArray')[0].get('aField')).toBe('aFieldValue');
25112511
expect(spy).toHaveBeenCalledTimes(2);
25122512
});
2513+
2514+
it('should have access to context in include query in beforeFind hook', async () => {
2515+
const obj1 = new Parse.Object('TestObject');
2516+
const obj2 = new Parse.Object('TestObject2');
2517+
obj2.set('aField', 'aFieldValue');
2518+
await obj2.save();
2519+
obj1.set('pointerField', obj2);
2520+
await obj1.save();
2521+
Parse.Cloud.beforeFind('TestObject', req => {
2522+
expect(req.context).toBeDefined();
2523+
expect(req.context.a).toEqual('a');
2524+
});
2525+
Parse.Cloud.beforeFind('TestObject2', req => {
2526+
expect(req.context).toBeDefined();
2527+
expect(req.context.a).toEqual('a');
2528+
});
2529+
const query = new Parse.Query('TestObject');
2530+
return query.include('pointerField').find({ context: { a: 'a' } });
2531+
});
25132532
});
25142533

25152534
describe('afterFind hooks', () => {

0 commit comments

Comments
 (0)