@@ -104,7 +104,7 @@ describe('APNS', () => {
104
104
105
105
var prodApnsConnection = apns . providers [ 0 ] ;
106
106
expect ( prodApnsConnection . index ) . toBe ( 0 ) ;
107
-
107
+
108
108
// TODO: Remove this checking onec we inject APNS
109
109
var prodApnsOptions = prodApnsConnection . client . config ;
110
110
expect ( prodApnsOptions . cert ) . toBe ( args [ 1 ] . cert ) ;
@@ -239,7 +239,7 @@ describe('APNS', () => {
239
239
expect ( notification . pushType ) . toEqual ( 'alert' ) ;
240
240
done ( ) ;
241
241
} ) ;
242
-
242
+
243
243
it ( 'can generate APNS notification from raw data' , ( done ) => {
244
244
//Mock request data
245
245
let data = {
@@ -259,17 +259,17 @@ describe('APNS', () => {
259
259
let collapseId = "collapseIdentifier" ;
260
260
let pushType = "background" ;
261
261
let priority = 5 ;
262
-
262
+
263
263
let notification = APNS . _generateNotification ( data , { expirationTime : expirationTime , collapseId : collapseId , pushType : pushType , priority : priority } ) ;
264
-
264
+
265
265
expect ( notification . expiry ) . toEqual ( Math . round ( expirationTime / 1000 ) ) ;
266
266
expect ( notification . collapseId ) . toEqual ( collapseId ) ;
267
267
expect ( notification . pushType ) . toEqual ( pushType ) ;
268
268
expect ( notification . priority ) . toEqual ( priority ) ;
269
-
269
+
270
270
let stringifiedJSON = notification . compile ( ) ;
271
271
let jsonObject = JSON . parse ( stringifiedJSON ) ;
272
-
272
+
273
273
expect ( jsonObject . aps . alert ) . toEqual ( { "loc-key" : "GAME_PLAY_REQUEST_FORMAT" , "loc-args" : [ "Jenna" , "Frank" ] } ) ;
274
274
expect ( jsonObject . aps . badge ) . toEqual ( 100 ) ;
275
275
expect ( jsonObject . aps . sound ) . toEqual ( 'test' ) ;
@@ -315,6 +315,20 @@ describe('APNS', () => {
315
315
done ( ) ;
316
316
} ) ;
317
317
318
+ it ( 'does log on invalid APNS notification' , async ( ) => {
319
+ const args = {
320
+ cert : new Buffer ( 'testCert' ) ,
321
+ key : new Buffer ( 'testKey' ) ,
322
+ production : true ,
323
+ topic : 'topic'
324
+ } ;
325
+ const log = require ( 'npmlog' ) ;
326
+ const spy = spyOn ( log , 'warn' ) ;
327
+ const apns = new APNS ( args ) ;
328
+ apns . send ( ) ;
329
+ expect ( spy ) . toHaveBeenCalled ( ) ;
330
+ } ) ;
331
+
318
332
it ( 'can send APNS notification' , ( done ) => {
319
333
let args = {
320
334
cert : new Buffer ( 'testCert' ) ,
0 commit comments