@@ -317,59 +317,62 @@ describe('AudiencesRouter', () => {
317317 ) ;
318318 } ) ;
319319
320- it_id ( 'af1111b5-3251-4b40-8f06-fb0fc624fa91' ) ( it_exclude_dbs ( [ 'postgres' ] ) ) ( 'should support legacy parse.com audience fields' , done => {
321- const database = Config . get ( Parse . applicationId ) . database . adapter . database ;
322- const now = new Date ( ) ;
323- Parse . _request (
324- 'POST' ,
325- 'push_audiences' ,
326- { name : 'My Audience' , query : JSON . stringify ( { deviceType : 'ios' } ) } ,
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 ( ) ;
320+ it_id ( 'af1111b5-3251-4b40-8f06-fb0fc624fa91' ) ( it_exclude_dbs ( [ 'postgres' ] ) ) (
321+ 'should support legacy parse.com audience fields' ,
322+ done => {
323+ const database = Config . get ( Parse . applicationId ) . database . adapter . database ;
324+ const now = new Date ( ) ;
325+ Parse . _request (
326+ 'POST' ,
327+ 'push_audiences' ,
328+ { name : 'My Audience' , query : JSON . stringify ( { deviceType : 'ios' } ) } ,
329+ { useMasterKey : true }
330+ ) . then ( audience => {
331+ database
332+ . collection ( 'test__Audience' )
333+ . updateOne (
334+ { _id : audience . objectId } ,
335+ {
336+ $set : {
337+ times_used : 1 ,
338+ _last_used : now ,
339+ } ,
340+ }
341+ )
342+ . then ( result => {
343+ expect ( result ) . toBeTruthy ( ) ;
342344
343- database
344- . collection ( 'test__Audience' )
345- . find ( { _id : audience . objectId } )
346- . toArray ( )
347- . then ( rows => {
348- expect ( rows [ 0 ] [ 'times_used' ] ) . toEqual ( 1 ) ;
349- expect ( rows [ 0 ] [ '_last_used' ] ) . toEqual ( now ) ;
350- Parse . _request (
351- 'GET' ,
352- 'push_audiences/' + audience . objectId ,
353- { } ,
354- { useMasterKey : true }
355- )
356- . then ( audience => {
357- expect ( audience . name ) . toEqual ( 'My Audience' ) ;
358- expect ( audience . query . deviceType ) . toEqual ( 'ios' ) ;
359- expect ( audience . timesUsed ) . toEqual ( 1 ) ;
360- expect ( audience . lastUsed ) . toEqual ( now . toISOString ( ) ) ;
361- done ( ) ;
362- } )
363- . catch ( error => {
364- done . fail ( error ) ;
365- } ) ;
366- } )
367- . catch ( error => {
368- done . fail ( error ) ;
369- } ) ;
370- } ) ;
371- } ) ;
372- } ) ;
345+ database
346+ . collection ( 'test__Audience' )
347+ . find ( { _id : audience . objectId } )
348+ . toArray ( )
349+ . then ( rows => {
350+ expect ( rows [ 0 ] [ 'times_used' ] ) . toEqual ( 1 ) ;
351+ expect ( rows [ 0 ] [ '_last_used' ] ) . toEqual ( now ) ;
352+ Parse . _request (
353+ 'GET' ,
354+ 'push_audiences/' + audience . objectId ,
355+ { } ,
356+ { useMasterKey : true }
357+ )
358+ . then ( audience => {
359+ expect ( audience . name ) . toEqual ( 'My Audience' ) ;
360+ expect ( audience . query . deviceType ) . toEqual ( 'ios' ) ;
361+ expect ( audience . timesUsed ) . toEqual ( 1 ) ;
362+ expect ( audience . lastUsed ) . toEqual ( now . toISOString ( ) ) ;
363+ done ( ) ;
364+ } )
365+ . catch ( error => {
366+ done . fail ( error ) ;
367+ } ) ;
368+ } )
369+ . catch ( error => {
370+ done . fail ( error ) ;
371+ } ) ;
372+ } ) ;
373+ } ) ;
374+ }
375+ ) ;
373376
374377 it ( 'should be able to search on audiences' , done => {
375378 Parse . _request (
0 commit comments