1
1
'use strict' ;
2
+
3
+
2
4
describe ( '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" ] ;
25
27
}
28
+ }
29
+
26
30
setServerConfiguration ( {
27
31
appId : Parse . applicationId ,
28
32
masterKey : Parse . masterKey ,
@@ -31,6 +35,7 @@ describe('Parse.Push', () => {
31
35
adapter : pushAdapter
32
36
}
33
37
} ) ;
38
+
34
39
var installations = [ ] ;
35
40
while ( installations . length != 10 ) {
36
41
var installation = new Parse . Object ( "_Installation" ) ;
@@ -41,21 +46,46 @@ describe('Parse.Push', () => {
41
46
installation . set ( "deviceType" , "ios" ) ;
42
47
installations . push ( installation ) ;
43
48
}
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 ( ( ) => {
45
54
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 } )
54
63
} )
55
64
. then ( ( ) => {
56
65
done ( ) ;
57
66
} , ( 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' )
59
89
done ( ) ;
60
90
} ) ;
61
91
} ) ;
0 commit comments