@@ -172,8 +172,9 @@ describe('APNS', () => {
172
172
} ;
173
173
let expirationTime = 1454571491354 ;
174
174
let collapseId = "collapseIdentifier" ;
175
+ let pushType = "alert"
175
176
176
- let notification = APNS . _generateNotification ( data , { expirationTime : expirationTime , collapseId : collapseId } ) ;
177
+ let notification = APNS . _generateNotification ( data , { expirationTime : expirationTime , collapseId : collapseId , pushType : pushType } ) ;
177
178
178
179
expect ( notification . aps . alert ) . toEqual ( { body : 'alert' , title : 'title' } ) ;
179
180
expect ( notification . aps . badge ) . toEqual ( data . badge ) ;
@@ -188,6 +189,7 @@ describe('APNS', () => {
188
189
} ) ;
189
190
expect ( notification . expiry ) . toEqual ( Math . round ( expirationTime / 1000 ) ) ;
190
191
expect ( notification . collapseId ) . toEqual ( collapseId ) ;
192
+ expect ( notification . pushType ) . toEqual ( pushType ) ;
191
193
done ( ) ;
192
194
} ) ;
193
195
@@ -208,11 +210,13 @@ describe('APNS', () => {
208
210
} ;
209
211
let expirationTime = 1454571491354 ;
210
212
let collapseId = "collapseIdentifier" ;
213
+ let pushType = "alert"
211
214
212
- let notification = APNS . _generateNotification ( data , { expirationTime : expirationTime , collapseId : collapseId } ) ;
215
+ let notification = APNS . _generateNotification ( data , { expirationTime : expirationTime , collapseId : collapseId , pushType : pushType } ) ;
213
216
214
217
expect ( notification . expiry ) . toEqual ( Math . round ( expirationTime / 1000 ) ) ;
215
218
expect ( notification . collapseId ) . toEqual ( collapseId ) ;
219
+ expect ( notification . pushType ) . toEqual ( pushType ) ;
216
220
217
221
let stringifiedJSON = notification . compile ( ) ;
218
222
let jsonObject = JSON . parse ( stringifiedJSON ) ;
@@ -280,8 +284,10 @@ describe('APNS', () => {
280
284
// Mock data
281
285
let expirationTime = 1454571491354 ;
282
286
let collapseId = "collapseIdentifier" ;
287
+ let pushType = "alert" // or background
283
288
let data = {
284
289
'collapse_id' : collapseId ,
290
+ 'push_type' : pushType ,
285
291
'expiration_time' : expirationTime ,
286
292
'data' : {
287
293
'alert' : 'alert'
@@ -312,7 +318,8 @@ describe('APNS', () => {
312
318
let notification = calledArgs [ 0 ] ;
313
319
expect ( notification . aps . alert ) . toEqual ( data . data . alert ) ;
314
320
expect ( notification . expiry ) . toEqual ( Math . round ( data [ 'expiration_time' ] / 1000 ) ) ;
315
- expect ( notification . collapseId ) . toEqual ( data [ 'collapse_id' ] ) ;
321
+ expect ( notification . collapseId ) . toEqual ( collapseId ) ;
322
+ expect ( notification . pushType ) . toEqual ( pushType ) ;
316
323
let apnDevices = calledArgs [ 1 ] ;
317
324
expect ( apnDevices . length ) . toEqual ( 4 ) ;
318
325
done ( ) ;
@@ -349,9 +356,11 @@ describe('APNS', () => {
349
356
apns . providers = [ provider , providerDev ] ;
350
357
// Mock data
351
358
let expirationTime = 1454571491354 ;
359
+ let pushType = "alert" // or background
352
360
let collapseId = "collapseIdentifier" ;
353
361
let data = {
354
362
'collapse_id' : collapseId ,
363
+ 'push_type' : pushType ,
355
364
'expiration_time' : expirationTime ,
356
365
'data' : {
357
366
'alert' : 'alert'
@@ -389,6 +398,7 @@ describe('APNS', () => {
389
398
expect ( notification . aps . alert ) . toEqual ( data . data . alert ) ;
390
399
expect ( notification . expiry ) . toEqual ( Math . round ( data [ 'expiration_time' ] / 1000 ) ) ;
391
400
expect ( notification . collapseId ) . toEqual ( data [ 'collapse_id' ] ) ;
401
+ expect ( notification . pushType ) . toEqual ( pushType ) ;
392
402
let apnDevices = calledArgs [ 1 ] ;
393
403
expect ( apnDevices . length ) . toBe ( 3 ) ;
394
404
@@ -398,6 +408,7 @@ describe('APNS', () => {
398
408
expect ( notification . aps . alert ) . toEqual ( data . data . alert ) ;
399
409
expect ( notification . expiry ) . toEqual ( Math . round ( data [ 'expiration_time' ] / 1000 ) ) ;
400
410
expect ( notification . collapseId ) . toEqual ( data [ 'collapse_id' ] ) ;
411
+ expect ( notification . pushType ) . toEqual ( pushType ) ;
401
412
apnDevices = calledArgs [ 1 ] ;
402
413
expect ( apnDevices . length ) . toBe ( 2 ) ;
403
414
done ( ) ;
0 commit comments