@@ -206,8 +206,9 @@ describe('Cloud Code', () => {
206
206
Parse . Cloud . beforeFind ( 'beforeFind' , ( ) => {
207
207
return new Parse . Object ( 'TestObject' , { foo : 'bar' } ) ;
208
208
} ) ;
209
- Parse . Cloud . afterFind ( 'beforeFind' , ( ) => {
210
- throw 'afterFind should not run' ;
209
+ Parse . Cloud . afterFind ( 'beforeFind' , req => {
210
+ expect ( req . objects ) . toBeDefined ( ) ;
211
+ expect ( req . objects [ 0 ] . get ( 'foo' ) ) . toBe ( 'bar' ) ;
211
212
} ) ;
212
213
const newObj = await new Parse . Query ( 'beforeFind' ) . first ( ) ;
213
214
expect ( newObj . className ) . toBe ( 'TestObject' ) ;
@@ -219,8 +220,9 @@ describe('Cloud Code', () => {
219
220
Parse . Cloud . beforeFind ( 'beforeFind' , ( ) => {
220
221
return [ new Parse . Object ( 'TestObject' , { foo : 'bar' } ) ] ;
221
222
} ) ;
222
- Parse . Cloud . afterFind ( 'beforeFind' , ( ) => {
223
- throw 'afterFind should not run' ;
223
+ Parse . Cloud . afterFind ( 'beforeFind' , req => {
224
+ expect ( req . objects ) . toBeDefined ( ) ;
225
+ expect ( req . objects [ 0 ] . get ( 'foo' ) ) . toBe ( 'bar' ) ;
224
226
} ) ;
225
227
const newObj = await new Parse . Query ( 'beforeFind' ) . first ( ) ;
226
228
expect ( newObj . className ) . toBe ( 'TestObject' ) ;
@@ -232,8 +234,9 @@ describe('Cloud Code', () => {
232
234
Parse . Cloud . beforeFind ( 'beforeFind' , ( ) => {
233
235
return [ new Parse . Object ( 'TestObject' , { foo : 'bar' } ) ] ;
234
236
} ) ;
235
- Parse . Cloud . afterFind ( 'beforeFind' , ( ) => {
236
- throw 'afterFind should not run' ;
237
+ Parse . Cloud . afterFind ( 'beforeFind' , req => {
238
+ expect ( req . objects ) . toBeDefined ( ) ;
239
+ expect ( req . objects [ 0 ] . get ( 'foo' ) ) . toBe ( 'bar' ) ;
237
240
} ) ;
238
241
const newObj = await new Parse . Query ( 'beforeFind' ) . get ( 'objId' ) ;
239
242
expect ( newObj . className ) . toBe ( 'TestObject' ) ;
@@ -245,8 +248,8 @@ describe('Cloud Code', () => {
245
248
Parse . Cloud . beforeFind ( 'beforeFind' , ( ) => {
246
249
return [ ] ;
247
250
} ) ;
248
- Parse . Cloud . afterFind ( 'beforeFind' , ( ) => {
249
- throw 'afterFind should not run' ;
251
+ Parse . Cloud . afterFind ( 'beforeFind' , req => {
252
+ expect ( req . objects . length ) . toBe ( 0 ) ;
250
253
} ) ;
251
254
const obj = new Parse . Object ( 'beforeFind' ) ;
252
255
await obj . save ( ) ;
0 commit comments