@@ -165,7 +165,7 @@ describe('PushWorker', () => {
165
165
const spy = spyOn ( config . database , "update" ) . and . callFake ( ( ) => {
166
166
return Promise . resolve ( ) ;
167
167
} ) ;
168
- handler . trackSent ( [
168
+ const toAwait = handler . trackSent ( [
169
169
{
170
170
transmitted : false ,
171
171
device : {
@@ -239,13 +239,13 @@ describe('PushWorker', () => {
239
239
expect ( lastCall . args [ 2 ] ) . toEqual ( {
240
240
deviceToken : { '__op' : "Delete" }
241
241
} ) ;
242
- done ( ) ;
242
+ toAwait . then ( done ) . catch ( done ) ;
243
243
} ) ;
244
244
245
245
it ( 'tracks push status per UTC offsets' , ( done ) => {
246
246
const config = new Config ( 'test' ) ;
247
- const handler = pushStatusHandler ( config , 'ABCDEF1234' ) ;
248
- const spy = spyOn ( config . database , "update " ) . and . callThrough ( ) ;
247
+ const handler = pushStatusHandler ( config ) ;
248
+ const spy = spyOn ( Parse , "_request " ) . and . callThrough ( ) ;
249
249
const UTCOffset = 1 ;
250
250
handler . setInitial ( ) . then ( ( ) => {
251
251
return handler . trackSent ( [
@@ -266,14 +266,9 @@ describe('PushWorker', () => {
266
266
] , UTCOffset )
267
267
} ) . then ( ( ) => {
268
268
expect ( spy ) . toHaveBeenCalled ( ) ;
269
- expect ( spy . calls . count ( ) ) . toBe ( 1 ) ;
270
269
const lastCall = spy . calls . mostRecent ( ) ;
271
- expect ( lastCall . args [ 0 ] ) . toBe ( '_PushStatus' ) ;
272
- const updatePayload = lastCall . args [ 2 ] ;
273
- expect ( updatePayload . updatedAt instanceof Date ) . toBeTruthy ( ) ;
274
- // remove the updatedAt as not testable
275
- delete updatePayload . updatedAt ;
276
-
270
+ expect ( lastCall . args [ 0 ] ) . toBe ( 'PUT' ) ;
271
+ expect ( lastCall . args [ 1 ] ) . toBe ( `classes/_PushStatus/${ handler . objectId } ` ) ;
277
272
expect ( lastCall . args [ 2 ] ) . toEqual ( {
278
273
numSent : { __op : 'Increment' , amount : 1 } ,
279
274
numFailed : { __op : 'Increment' , amount : 1 } ,
@@ -284,7 +279,7 @@ describe('PushWorker', () => {
284
279
count : { __op : 'Increment' , amount : - 2 } ,
285
280
} ) ;
286
281
const query = new Parse . Query ( '_PushStatus' ) ;
287
- return query . get ( 'ABCDEF1234' , { useMasterKey : true } ) ;
282
+ return query . get ( handler . objectId , { useMasterKey : true } ) ;
288
283
} ) . then ( ( pushStatus ) => {
289
284
const sentPerUTCOffset = pushStatus . get ( 'sentPerUTCOffset' ) ;
290
285
expect ( sentPerUTCOffset [ '1' ] ) . toBe ( 1 ) ;
@@ -315,7 +310,7 @@ describe('PushWorker', () => {
315
310
] , UTCOffset )
316
311
} ) . then ( ( ) => {
317
312
const query = new Parse . Query ( '_PushStatus' ) ;
318
- return query . get ( 'ABCDEF1234' , { useMasterKey : true } ) ;
313
+ return query . get ( handler . objectId , { useMasterKey : true } ) ;
319
314
} ) . then ( ( pushStatus ) => {
320
315
const sentPerUTCOffset = pushStatus . get ( 'sentPerUTCOffset' ) ;
321
316
expect ( sentPerUTCOffset [ '1' ] ) . toBe ( 3 ) ;
@@ -330,7 +325,7 @@ describe('PushWorker', () => {
330
325
spyOn ( config . database , "create" ) . and . callFake ( ( ) => {
331
326
return Promise . resolve ( ) ;
332
327
} ) ;
333
- const spy = spyOn ( config . database , "update " ) . and . callFake ( ( ) => {
328
+ const spy = spyOn ( Parse , "_request " ) . and . callFake ( ( ) => {
334
329
return Promise . resolve ( ) ;
335
330
} ) ;
336
331
const UTCOffset = - 6 ;
@@ -353,14 +348,8 @@ describe('PushWorker', () => {
353
348
} ,
354
349
] , UTCOffset ) . then ( ( ) => {
355
350
expect ( spy ) . toHaveBeenCalled ( ) ;
356
- expect ( spy . calls . count ( ) ) . toBe ( 1 ) ;
357
351
const lastCall = spy . calls . mostRecent ( ) ;
358
- expect ( lastCall . args [ 0 ] ) . toBe ( '_PushStatus' ) ;
359
- const updatePayload = lastCall . args [ 2 ] ;
360
- expect ( updatePayload . updatedAt instanceof Date ) . toBeTruthy ( ) ;
361
- // remove the updatedAt as not testable
362
- delete updatePayload . updatedAt ;
363
-
352
+ expect ( lastCall . args [ 1 ] ) . toBe ( `classes/_PushStatus/${ handler . objectId } ` ) ;
364
353
expect ( lastCall . args [ 2 ] ) . toEqual ( {
365
354
numSent : { __op : 'Increment' , amount : 1 } ,
366
355
numFailed : { __op : 'Increment' , amount : 1 } ,
0 commit comments