@@ -387,10 +387,10 @@ describe('Hooks', () => {
387387 Parse . Hooks . createTrigger ( "SomeRandomObject" , "beforeSave" , hookServerURL + "/BeforeSaveSome" ) . then ( function ( ) {
388388 const obj = new Parse . Object ( "SomeRandomObject" ) ;
389389 return obj . save ( ) ;
390- } ) . then ( function ( res ) {
390+ } ) . then ( function ( res ) {
391391 expect ( triggerCount ) . toBe ( 1 ) ;
392392 return res . fetch ( ) ;
393- } ) . then ( function ( res ) {
393+ } ) . then ( function ( res ) {
394394 expect ( res . get ( "hello" ) ) . toEqual ( "world" ) ;
395395 done ( ) ;
396396 } ) . fail ( ( err ) => {
@@ -400,6 +400,26 @@ describe('Hooks', () => {
400400 } ) ;
401401 } ) ;
402402
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+
403423 it ( "should run the afterSave hook on the test server" , ( done ) => {
404424 var triggerCount = 0 ;
405425 var newObjectId ;
0 commit comments