@@ -317,54 +317,41 @@ describe('AudiencesRouter', () => {
317
317
) ;
318
318
} ) ;
319
319
320
- it_exclude_dbs ( [ 'postgres' ] ) ( 'should support legacy parse.com audience fields' , done => {
320
+ it_exclude_dbs ( [ 'postgres' ] ) ( 'should support legacy parse.com audience fields' , async ( ) => {
321
321
const database = Config . get ( Parse . applicationId ) . database . adapter . database ;
322
322
const now = new Date ( ) ;
323
- Parse . _request (
323
+ let audience = await Parse . _request (
324
324
'POST' ,
325
325
'push_audiences' ,
326
326
{ name : 'My Audience' , query : JSON . stringify ( { deviceType : 'ios' } ) } ,
327
327
{ useMasterKey : true }
328
- ) . then ( audience => {
329
- database
330
- . collection ( 'test__Audience' )
331
- . updateOne (
332
- { _id : audience . objectId } ,
333
- {
334
- $set : {
335
- times_used : 1 ,
336
- _last_used : now ,
337
- } ,
338
- }
339
- )
340
- . then ( result => {
341
- expect ( result ) . toBeTruthy ( ) ;
342
- database
343
- . collection ( 'test__Audience' )
344
- . find ( { _id : audience . objectId } )
345
- . toArray ( ( error , rows ) => {
346
- expect ( error ) . toEqual ( undefined ) ;
347
- expect ( rows [ 0 ] [ 'times_used' ] ) . toEqual ( 1 ) ;
348
- expect ( rows [ 0 ] [ '_last_used' ] ) . toEqual ( now ) ;
349
- Parse . _request (
350
- 'GET' ,
351
- 'push_audiences/' + audience . objectId ,
352
- { } ,
353
- { useMasterKey : true }
354
- )
355
- . then ( audience => {
356
- expect ( audience . name ) . toEqual ( 'My Audience' ) ;
357
- expect ( audience . query . deviceType ) . toEqual ( 'ios' ) ;
358
- expect ( audience . timesUsed ) . toEqual ( 1 ) ;
359
- expect ( audience . lastUsed ) . toEqual ( now . toISOString ( ) ) ;
360
- done ( ) ;
361
- } )
362
- . catch ( error => {
363
- done . fail ( error ) ;
364
- } ) ;
365
- } ) ;
366
- } ) ;
367
- } ) ;
328
+ ) ;
329
+ const result = await database . collection ( 'test__Audience' ) . updateOne (
330
+ { _id : audience . objectId } ,
331
+ {
332
+ $set : {
333
+ times_used : 1 ,
334
+ _last_used : now ,
335
+ } ,
336
+ }
337
+ ) ;
338
+ expect ( result ) . toBeTruthy ( ) ;
339
+ const rows = await database
340
+ . collection ( 'test__Audience' )
341
+ . find ( { _id : audience . objectId } )
342
+ . toArray ( ) ;
343
+ expect ( rows [ 0 ] [ 'times_used' ] ) . toEqual ( 1 ) ;
344
+ expect ( rows [ 0 ] [ '_last_used' ] ) . toEqual ( now ) ;
345
+ audience = await Parse . _request (
346
+ 'GET' ,
347
+ 'push_audiences/' + audience . objectId ,
348
+ { } ,
349
+ { useMasterKey : true }
350
+ ) ;
351
+ expect ( audience . name ) . toEqual ( 'My Audience' ) ;
352
+ expect ( audience . query . deviceType ) . toEqual ( 'ios' ) ;
353
+ expect ( audience . timesUsed ) . toEqual ( 1 ) ;
354
+ expect ( audience . lastUsed ) . toEqual ( now . toISOString ( ) ) ;
368
355
} ) ;
369
356
370
357
it ( 'should be able to search on audiences' , done => {
0 commit comments