@@ -485,26 +485,37 @@ describe('PushController', () => {
485
485
expect ( spy ) . toHaveBeenCalled ( ) ;
486
486
expect ( spy . calls . count ( ) ) . toBe ( 4 ) ;
487
487
const allCalls = spy . calls . all ( ) ;
488
- allCalls . forEach ( call => {
488
+ let pendingCount = 0 ;
489
+ let runningCount = 0 ;
490
+ let succeedCount = 0 ;
491
+ allCalls . forEach ( ( call , index ) => {
489
492
expect ( call . args . length ) . toBe ( 1 ) ;
490
493
const object = call . args [ 0 ] . object ;
491
494
expect ( object instanceof Parse . Object ) . toBe ( true ) ;
495
+ const pushStatus = getPushStatus ( index ) ;
496
+ if ( pushStatus . get ( 'status' ) === 'pending' ) {
497
+ pendingCount += 1 ;
498
+ }
499
+ if ( pushStatus . get ( 'status' ) === 'running' ) {
500
+ runningCount += 1 ;
501
+ }
502
+ if ( pushStatus . get ( 'status' ) === 'succeeded' ) {
503
+ succeedCount += 1 ;
504
+ }
505
+ if ( pushStatus . get ( 'status' ) === 'running' && pushStatus . get ( 'numSent' ) > 0 ) {
506
+ expect ( pushStatus . get ( 'numSent' ) ) . toBe ( 10 ) ;
507
+ expect ( pushStatus . get ( 'numFailed' ) ) . toBe ( 5 ) ;
508
+ expect ( pushStatus . get ( 'failedPerType' ) ) . toEqual ( {
509
+ android : 5 ,
510
+ } ) ;
511
+ expect ( pushStatus . get ( 'sentPerType' ) ) . toEqual ( {
512
+ ios : 10 ,
513
+ } ) ;
514
+ }
492
515
} ) ;
493
- expect ( getPushStatus ( 0 ) . get ( 'status' ) ) . toBe ( 'pending' ) ;
494
- expect ( getPushStatus ( 1 ) . get ( 'status' ) ) . toBe ( 'running' ) ;
495
- expect ( getPushStatus ( 1 ) . get ( 'numSent' ) ) . toBe ( 0 ) ;
496
- expect ( getPushStatus ( 2 ) . get ( 'status' ) ) . toBe ( 'running' ) ;
497
- expect ( getPushStatus ( 2 ) . get ( 'numSent' ) ) . toBe ( 10 ) ;
498
- expect ( getPushStatus ( 2 ) . get ( 'numFailed' ) ) . toBe ( 5 ) ;
499
- // Those are updated from a nested . operation, this would
500
- // not render correctly before
501
- expect ( getPushStatus ( 2 ) . get ( 'failedPerType' ) ) . toEqual ( {
502
- android : 5 ,
503
- } ) ;
504
- expect ( getPushStatus ( 2 ) . get ( 'sentPerType' ) ) . toEqual ( {
505
- ios : 10 ,
506
- } ) ;
507
- expect ( getPushStatus ( 3 ) . get ( 'status' ) ) . toBe ( 'succeeded' ) ;
516
+ expect ( pendingCount ) . toBe ( 1 ) ;
517
+ expect ( runningCount ) . toBe ( 2 ) ;
518
+ expect ( succeedCount ) . toBe ( 1 ) ;
508
519
} ) ;
509
520
510
521
it ( 'properly creates _PushStatus without serverURL' , async ( ) => {
0 commit comments