@@ -1239,6 +1239,56 @@ describe('Installations', () => {
12391239 } ) ;
12401240 } ) ;
12411241
1242+ it ( 'can use push with beforeSave' , async ( ) => {
1243+ const input = {
1244+ deviceToken : '11433856eed2f1285fb3aa11136718c1198ed5647875096952c66bf8cb976306' ,
1245+ deviceType : 'ios' ,
1246+ } ;
1247+ await rest . create ( config , auth . nobody ( config ) , '_Installation' , input )
1248+ const functions = {
1249+ beforeSave ( ) { } ,
1250+ afterSave ( ) { }
1251+ }
1252+ spyOn ( functions , 'beforeSave' ) . and . callThrough ( ) ;
1253+ spyOn ( functions , 'afterSave' ) . and . callThrough ( ) ;
1254+ Parse . Cloud . beforeSave ( Parse . Installation , functions . beforeSave ) ;
1255+ Parse . Cloud . afterSave ( Parse . Installation , functions . afterSave ) ;
1256+ await Parse . Push . send ( {
1257+ where : {
1258+ deviceType : 'ios' ,
1259+ } ,
1260+ data : {
1261+ badge : 'increment' ,
1262+ alert : 'Hello world!' ,
1263+ } ,
1264+ } ) ;
1265+
1266+ await Parse . Push . send ( {
1267+ where : {
1268+ deviceType : 'ios' ,
1269+ } ,
1270+ data : {
1271+ badge : 'increment' ,
1272+ alert : 'Hello world!' ,
1273+ } ,
1274+ } ) ;
1275+
1276+ await Parse . Push . send ( {
1277+ where : {
1278+ deviceType : 'ios' ,
1279+ } ,
1280+ data : {
1281+ badge : 'increment' ,
1282+ alert : 'Hello world!' ,
1283+ } ,
1284+ } ) ;
1285+ await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
1286+ const installation = await new Parse . Query ( Parse . Installation ) . first ( { useMasterKey : true } ) ;
1287+ expect ( installation . get ( 'badge' ) ) . toEqual ( 3 ) ;
1288+ expect ( functions . beforeSave ) . not . toHaveBeenCalled ( ) ;
1289+ expect ( functions . afterSave ) . not . toHaveBeenCalled ( ) ;
1290+ } ) ;
1291+
12421292 // TODO: Look at additional tests from installation_collection_test.go:882
12431293 // TODO: Do we need to support _tombstone disabling of installations?
12441294 // TODO: Test deletion, badge increments
0 commit comments