1
1
'use strict' ;
2
- 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
- }
2
+
3
+
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 ( ) ;
25
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
+ }
25
+ }
26
+
27
+ describe ( 'Parse.Push' , ( ) => {
28
+
29
+ beforeEach ( ( done ) => {
26
30
setServerConfiguration ( {
27
31
appId : Parse . applicationId ,
28
32
masterKey : Parse . masterKey ,
@@ -42,20 +46,44 @@ describe('Parse.Push', () => {
42
46
installations . push ( installation ) ;
43
47
}
44
48
Parse . Object . saveAll ( installations ) . then ( ( ) => {
45
- return Parse . Push . send ( {
46
- where : {
47
- deviceType : 'ios'
48
- } ,
49
- data : {
50
- badge : 'Increment' ,
51
- alert : 'Hello world!'
52
- }
53
- } , { useMasterKey : true } ) ;
49
+ done ( ) ;
54
50
} )
51
+ } )
52
+
53
+ it ( 'should properly send push' , ( done ) => {
54
+ return Parse . Push . send ( {
55
+ where : {
56
+ deviceType : 'ios'
57
+ } ,
58
+ data : {
59
+ badge : 'Increment' ,
60
+ alert : 'Hello world!'
61
+ }
62
+ } , { useMasterKey : true } )
63
+ . then ( ( ) => {
64
+ done ( ) ;
65
+ } , ( err ) => {
66
+ console . error ( ) ;
67
+ fail ( 'should not fail sending push' )
68
+ done ( ) ;
69
+ } ) ;
70
+ } ) ;
71
+
72
+ it ( 'should properly send push with lowercaseIncrement' , ( done ) => {
73
+ return Parse . Push . send ( {
74
+ where : {
75
+ deviceType : 'ios'
76
+ } ,
77
+ data : {
78
+ badge : 'increment' ,
79
+ alert : 'Hello world!'
80
+ }
81
+ } , { useMasterKey : true } )
55
82
. then ( ( ) => {
56
83
done ( ) ;
57
84
} , ( err ) => {
58
- console . error ( err ) ;
85
+ console . error ( ) ;
86
+ fail ( 'should not fail sending push' )
59
87
done ( ) ;
60
88
} ) ;
61
89
} ) ;
0 commit comments