@@ -143,7 +143,9 @@ describe('Hooks', () => {
143
143
} ) ;
144
144
145
145
it ( "should fail trying to create two times the same function" , ( done ) => {
146
- Parse . Hooks . createFunction ( "my_new_function" , "http://url.com" ) . then ( ( ) => {
146
+ Parse . Hooks . createFunction ( "my_new_function" , "http://url.com" )
147
+ . then ( ( ) => new Promise ( resolve => setTimeout ( resolve , 100 ) ) )
148
+ . then ( ( ) => {
147
149
return Parse . Hooks . createFunction ( "my_new_function" , "http://url.com" )
148
150
} , ( ) => {
149
151
fail ( "should create a new function" ) ;
@@ -421,8 +423,8 @@ describe('Hooks', () => {
421
423
// But this should override the key upon return
422
424
res . json ( { success : object } ) ;
423
425
} ) ;
424
- // The function is delete as the DB is dropped between calls
425
- Parse . Hooks . createTrigger ( "SomeRandomObject" , "beforeSave" , hookServerURL + "/BeforeSaveSome" ) . then ( function ( ) {
426
+ // The function is deleted as the DB is dropped between calls
427
+ Parse . Hooks . createTrigger ( "SomeRandomObject" , "beforeSave" , hookServerURL + "/BeforeSaveSome" ) . then ( function ( ) {
426
428
const obj = new Parse . Object ( "SomeRandomObject" ) ;
427
429
return obj . save ( ) ;
428
430
} ) . then ( function ( res ) {
@@ -444,7 +446,7 @@ describe('Hooks', () => {
444
446
object . set ( 'hello' , "world" ) ;
445
447
res . json ( { success : object } ) ;
446
448
} ) ;
447
- Parse . Hooks . createTrigger ( "SomeRandomObject2" , "beforeSave" , hookServerURL + "/BeforeSaveSome2" ) . then ( function ( ) {
449
+ Parse . Hooks . createTrigger ( "SomeRandomObject2" , "beforeSave" , hookServerURL + "/BeforeSaveSome2" ) . then ( function ( ) {
448
450
const obj = new Parse . Object ( "SomeRandomObject2" ) ;
449
451
return obj . save ( ) ;
450
452
} ) . then ( function ( res ) {
@@ -470,20 +472,19 @@ describe('Hooks', () => {
470
472
res . json ( { success : { } } ) ;
471
473
} )
472
474
} ) ;
473
- // The function is delete as the DB is dropped between calls
474
- Parse . Hooks . createTrigger ( "SomeRandomObject" , "afterSave" , hookServerURL + "/AfterSaveSome" ) . then ( function ( ) {
475
+ // The function is deleted as the DB is dropped between calls
476
+ Parse . Hooks . createTrigger ( "SomeRandomObject" , "afterSave" , hookServerURL + "/AfterSaveSome" ) . then ( function ( ) {
475
477
const obj = new Parse . Object ( "SomeRandomObject" ) ;
476
478
return obj . save ( ) ;
477
479
} ) . then ( function ( ) {
478
480
var promise = new Parse . Promise ( ) ;
479
- // Wait a bit here as it's an after save
480
- setTimeout ( function ( ) {
481
+ // Wait a bit here as it's an after save
482
+ setTimeout ( ( ) => {
481
483
expect ( triggerCount ) . toBe ( 1 ) ;
482
- var q = new Parse . Query ( "AnotherObject" ) ;
483
- q . get ( newObjectId ) . then ( function ( r ) {
484
- promise . resolve ( r ) ;
485
- } ) ;
486
- } , 300 )
484
+ new Parse . Query ( "AnotherObject" )
485
+ . get ( newObjectId )
486
+ . then ( ( r ) => promise . resolve ( r ) ) ;
487
+ } , 500 ) ;
487
488
return promise ;
488
489
} ) . then ( function ( res ) {
489
490
expect ( res . get ( "foo" ) ) . toEqual ( "bar" ) ;
0 commit comments