File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -2510,6 +2510,25 @@ describe('beforeFind hooks', () => {
2510
2510
expect ( res2 . get ( 'pointerFieldArray' ) [ 0 ] . get ( 'aField' ) ) . toBe ( 'aFieldValue' ) ;
2511
2511
expect ( spy ) . toHaveBeenCalledTimes ( 2 ) ;
2512
2512
} ) ;
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
+ } ) ;
2513
2532
} ) ;
2514
2533
2515
2534
describe ( 'afterFind hooks' , ( ) => {
You can’t perform that action at this time.
0 commit comments