@@ -387,10 +387,10 @@ describe('Hooks', () => {
387
387
Parse . Hooks . createTrigger ( "SomeRandomObject" , "beforeSave" , hookServerURL + "/BeforeSaveSome" ) . then ( function ( ) {
388
388
const obj = new Parse . Object ( "SomeRandomObject" ) ;
389
389
return obj . save ( ) ;
390
- } ) . then ( function ( res ) {
390
+ } ) . then ( function ( res ) {
391
391
expect ( triggerCount ) . toBe ( 1 ) ;
392
392
return res . fetch ( ) ;
393
- } ) . then ( function ( res ) {
393
+ } ) . then ( function ( res ) {
394
394
expect ( res . get ( "hello" ) ) . toEqual ( "world" ) ;
395
395
done ( ) ;
396
396
} ) . fail ( ( err ) => {
@@ -400,6 +400,26 @@ describe('Hooks', () => {
400
400
} ) ;
401
401
} ) ;
402
402
403
+ it ( "beforeSave hooks should correctly handle responses containing entire object" , ( done ) => {
404
+ app . post ( "/BeforeSaveSome2" , function ( req , res ) {
405
+ var object = Parse . Object . fromJSON ( req . body . object ) ;
406
+ object . set ( 'hello' , "world" ) ;
407
+ res . json ( { success : object } ) ;
408
+ } ) ;
409
+ Parse . Hooks . createTrigger ( "SomeRandomObject2" , "beforeSave" , hookServerURL + "/BeforeSaveSome2" ) . then ( function ( ) {
410
+ const obj = new Parse . Object ( "SomeRandomObject2" ) ;
411
+ return obj . save ( ) ;
412
+ } ) . then ( function ( res ) {
413
+ return res . save ( ) ;
414
+ } ) . then ( function ( res ) {
415
+ expect ( res . get ( "hello" ) ) . toEqual ( "world" ) ;
416
+ done ( ) ;
417
+ } ) . fail ( ( err ) => {
418
+ fail ( `Should not fail: ${ JSON . stringify ( err ) } ` ) ;
419
+ done ( ) ;
420
+ } ) ;
421
+ } ) ;
422
+
403
423
it ( "should run the afterSave hook on the test server" , ( done ) => {
404
424
var triggerCount = 0 ;
405
425
var newObjectId ;
0 commit comments