@@ -562,11 +562,7 @@ describe('PushController', () => {
562
562
} ) ;
563
563
const pushStatusId = await sendPush ( payload , { } , config , auth ) ;
564
564
// it is enqueued so it can take time
565
- await new Promise ( resolve => {
566
- setTimeout ( ( ) => {
567
- resolve ( ) ;
568
- } , 1000 ) ;
569
- } ) ;
565
+ await sleep ( 1000 ) ;
570
566
Parse . serverURL = 'http://localhost:8378/1' ; // GOOD url
571
567
const result = await Parse . Push . getPushStatus ( pushStatusId ) ;
572
568
expect ( result ) . toBeDefined ( ) ;
@@ -767,7 +763,7 @@ describe('PushController', () => {
767
763
} ) ;
768
764
} ) ;
769
765
770
- it ( 'should not schedule push when not configured' , done => {
766
+ it ( 'should not schedule push when not configured' , async ( ) => {
771
767
const config = Config . get ( Parse . applicationId ) ;
772
768
const auth = {
773
769
isMaster : true ,
@@ -800,33 +796,20 @@ describe('PushController', () => {
800
796
installations . push ( installation ) ;
801
797
}
802
798
803
- reconfigureServer ( {
799
+ await reconfigureServer ( {
804
800
push : { adapter : pushAdapter } ,
805
- } )
806
- . then ( ( ) => {
807
- return Parse . Object . saveAll ( installations )
808
- . then ( ( ) => {
809
- return pushController . sendPush ( payload , { } , config , auth ) ;
810
- } )
811
- . then ( ( ) => new Promise ( resolve => setTimeout ( resolve , 300 ) ) ) ;
812
- } )
813
- . then ( ( ) => {
814
- const query = new Parse . Query ( '_PushStatus' ) ;
815
- return query . find ( { useMasterKey : true } ) . then ( results => {
816
- expect ( results . length ) . toBe ( 1 ) ;
817
- const pushStatus = results [ 0 ] ;
818
- expect ( pushStatus . get ( 'status' ) ) . not . toBe ( 'scheduled' ) ;
819
- done ( ) ;
820
- } ) ;
821
- } )
822
- . catch ( err => {
823
- console . error ( err ) ;
824
- fail ( 'should not fail' ) ;
825
- done ( ) ;
826
- } ) ;
801
+ } ) ;
802
+ await Parse . Object . saveAll ( installations ) ;
803
+ await pushController . sendPush ( payload , { } , config , auth ) ;
804
+ await sleep ( 1000 ) ;
805
+ const query = new Parse . Query ( '_PushStatus' ) ;
806
+ const results = await query . find ( { useMasterKey : true } ) ;
807
+ expect ( results . length ) . toBe ( 1 ) ;
808
+ const pushStatus = results [ 0 ] ;
809
+ expect ( pushStatus . get ( 'status' ) ) . not . toBe ( 'scheduled' ) ;
827
810
} ) ;
828
811
829
- it ( 'should schedule push when configured' , done => {
812
+ it ( 'should schedule push when configured' , async ( ) => {
830
813
const auth = {
831
814
isMaster : true ,
832
815
} ;
@@ -866,28 +849,19 @@ describe('PushController', () => {
866
849
installation . set ( 'deviceType' , 'ios' ) ;
867
850
installations . push ( installation ) ;
868
851
}
869
- reconfigureServer ( {
852
+ await reconfigureServer ( {
870
853
push : { adapter : pushAdapter } ,
871
854
scheduledPush : true ,
872
- } )
873
- . then ( ( ) => {
874
- const config = Config . get ( Parse . applicationId ) ;
875
- return Parse . Object . saveAll ( installations )
876
- . then ( ( ) => {
877
- return pushController . sendPush ( payload , { } , config , auth ) ;
878
- } )
879
- . then ( ( ) => new Promise ( resolve => setTimeout ( resolve , 300 ) ) ) ;
880
- } )
881
- . then ( ( ) => {
882
- const query = new Parse . Query ( '_PushStatus' ) ;
883
- return query . find ( { useMasterKey : true } ) . then ( results => {
884
- expect ( results . length ) . toBe ( 1 ) ;
885
- const pushStatus = results [ 0 ] ;
886
- expect ( pushStatus . get ( 'status' ) ) . toBe ( 'scheduled' ) ;
887
- } ) ;
888
- } )
889
- . then ( done )
890
- . catch ( done . err ) ;
855
+ } ) ;
856
+ const config = Config . get ( Parse . applicationId ) ;
857
+ await Parse . Object . saveAll ( installations ) ;
858
+ await pushController . sendPush ( payload , { } , config , auth ) ;
859
+ await sleep ( 1000 ) ;
860
+ const query = new Parse . Query ( '_PushStatus' ) ;
861
+ const results = await query . find ( { useMasterKey : true } ) ;
862
+ expect ( results . length ) . toBe ( 1 ) ;
863
+ const pushStatus = results [ 0 ] ;
864
+ expect ( pushStatus . get ( 'status' ) ) . toBe ( 'scheduled' ) ;
891
865
} ) ;
892
866
893
867
it ( 'should not enqueue push when device token is not set' , async ( ) => {
0 commit comments