File tree 1 file changed +20
-5
lines changed
1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,14 @@ const delayPromise = (delay) => {
10
10
11
11
describe ( 'Parse.Push' , ( ) => {
12
12
var setup = function ( ) {
13
+ var sendToInstallationSpy = jasmine . createSpy ( ) ;
14
+
13
15
var pushAdapter = {
14
16
send : function ( body , installations ) {
15
17
var badge = body . data . badge ;
16
18
const promises = installations . map ( ( installation ) => {
19
+ sendToInstallationSpy ( installation ) ;
20
+
17
21
if ( installation . deviceType == "ios" ) {
18
22
expect ( installation . badge ) . toEqual ( badge ) ;
19
23
expect ( installation . originalBadge + 1 ) . toEqual ( installation . badge ) ;
@@ -53,13 +57,21 @@ describe('Parse.Push', () => {
53
57
installations . push ( installation ) ;
54
58
}
55
59
return Parse . Object . saveAll ( installations ) ;
56
- } ) . catch ( ( err ) => {
60
+ } )
61
+ . then ( ( ) => {
62
+ return {
63
+ sendToInstallationSpy,
64
+ } ;
65
+ } )
66
+ . catch ( ( err ) => {
57
67
console . error ( err ) ;
68
+
69
+ throw err ;
58
70
} )
59
71
}
60
72
61
73
it ( 'should properly send push' , ( done ) => {
62
- return setup ( ) . then ( ( ) => {
74
+ return setup ( ) . then ( ( { sendToInstallationSpy } ) => {
63
75
return Parse . Push . send ( {
64
76
where : {
65
77
deviceType : 'ios'
@@ -69,10 +81,13 @@ describe('Parse.Push', () => {
69
81
alert : 'Hello world!'
70
82
}
71
83
} , { useMasterKey : true } )
84
+ . then ( ( ) => {
85
+ return delayPromise ( 500 ) ;
86
+ } )
87
+ . then ( ( ) => {
88
+ expect ( sendToInstallationSpy . calls . count ( ) ) . toEqual ( 10 ) ;
89
+ } )
72
90
} ) . then ( ( ) => {
73
- return delayPromise ( 500 ) ;
74
- } )
75
- . then ( ( ) => {
76
91
done ( ) ;
77
92
} ) . catch ( ( err ) => {
78
93
jfail ( err ) ;
You can’t perform that action at this time.
0 commit comments