11'use strict' ;
2+
3+
24describe ( 'Parse.Push' , ( ) => {
3- it ( 'should properly send push' , ( done ) => {
4- var pushAdapter = {
5- send : function ( body , installations ) {
6- var badge = body . data . badge ;
7- let promises = installations . map ( ( installation ) => {
8- if ( installation . deviceType == "ios" ) {
9- expect ( installation . badge ) . toEqual ( badge ) ;
10- expect ( installation . originalBadge + 1 ) . toEqual ( installation . badge ) ;
11- } else {
12- expect ( installation . badge ) . toBeUndefined ( ) ;
13- }
14- return Promise . resolve ( {
15- err : null ,
16- deviceType : installation . deviceType ,
17- result : true
18- } )
19- } ) ;
20- return Promise . all ( promises )
21- } ,
22- getValidPushTypes : function ( ) {
23- return [ "ios" , "android" ] ;
24- }
5+
6+ var setup = function ( ) {
7+ var pushAdapter = {
8+ send : function ( body , installations ) {
9+ var badge = body . data . badge ;
10+ let promises = installations . map ( ( installation ) => {
11+ if ( installation . deviceType == "ios" ) {
12+ expect ( installation . badge ) . toEqual ( badge ) ;
13+ expect ( installation . originalBadge + 1 ) . toEqual ( installation . badge ) ;
14+ } else {
15+ expect ( installation . badge ) . toBeUndefined ( ) ;
16+ }
17+ return Promise . resolve ( {
18+ err : null ,
19+ deviceType : installation . deviceType ,
20+ result : true
21+ } )
22+ } ) ;
23+ return Promise . all ( promises ) ;
24+ } ,
25+ getValidPushTypes : function ( ) {
26+ return [ "ios" , "android" ] ;
2527 }
28+ }
29+
2630 setServerConfiguration ( {
2731 appId : Parse . applicationId ,
2832 masterKey : Parse . masterKey ,
@@ -31,6 +35,7 @@ describe('Parse.Push', () => {
3135 adapter : pushAdapter
3236 }
3337 } ) ;
38+
3439 var installations = [ ] ;
3540 while ( installations . length != 10 ) {
3641 var installation = new Parse . Object ( "_Installation" ) ;
@@ -41,21 +46,46 @@ describe('Parse.Push', () => {
4146 installation . set ( "deviceType" , "ios" ) ;
4247 installations . push ( installation ) ;
4348 }
44- Parse . Object . saveAll ( installations ) . then ( ( ) => {
49+ return Parse . Object . saveAll ( installations ) ;
50+ }
51+
52+ it ( 'should properly send push' , ( done ) => {
53+ return setup ( ) . then ( ( ) => {
4554 return Parse . Push . send ( {
46- where : {
47- deviceType : 'ios'
48- } ,
49- data : {
50- badge : 'Increment' ,
51- alert : 'Hello world!'
52- }
53- } , { useMasterKey : true } ) ;
55+ where : {
56+ deviceType : 'ios'
57+ } ,
58+ data : {
59+ badge : 'Increment' ,
60+ alert : 'Hello world!'
61+ }
62+ } , { useMasterKey : true } )
5463 } )
5564 . then ( ( ) => {
5665 done ( ) ;
5766 } , ( err ) => {
58- console . error ( err ) ;
67+ console . error ( ) ;
68+ fail ( 'should not fail sending push' )
69+ done ( ) ;
70+ } ) ;
71+ } ) ;
72+
73+ it ( 'should properly send push with lowercaseIncrement' , ( done ) => {
74+ return setup ( ) . then ( ( ) => {
75+ return Parse . Push . send ( {
76+ where : {
77+ deviceType : 'ios'
78+ } ,
79+ data : {
80+ badge : 'increment' ,
81+ alert : 'Hello world!'
82+ }
83+ } , { useMasterKey : true } )
84+ } ) . then ( ( ) => {
85+ done ( ) ;
86+ } , ( err ) => {
87+ console . error ( ) ;
88+ fail ( 'should not fail sending push' )
5989 done ( ) ;
6090 } ) ;
6191 } ) ;
0 commit comments