From 05aba62f1cbbca7d5d3e80b9444529f59407cb56 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sat, 13 Mar 2021 10:47:56 -0600 Subject: [PATCH] fix push tests --- spec/Parse.Push.spec.js | 7 +++++++ spec/PushController.spec.js | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/spec/Parse.Push.spec.js b/spec/Parse.Push.spec.js index 33d36b43af..3463277125 100644 --- a/spec/Parse.Push.spec.js +++ b/spec/Parse.Push.spec.js @@ -2,11 +2,18 @@ const request = require('../lib/request'); +function sleep(ms) { + return new Promise(function (resolve) { + setTimeout(resolve, ms); + }); +} + const pushCompleted = async pushId => { const query = new Parse.Query('_PushStatus'); query.equalTo('objectId', pushId); let result = await query.first({ useMasterKey: true }); while (!(result && result.get('status') === 'succeeded')) { + await sleep(1000); result = await query.first({ useMasterKey: true }); } }; diff --git a/spec/PushController.spec.js b/spec/PushController.spec.js index 7b5d750b66..1bf185e467 100644 --- a/spec/PushController.spec.js +++ b/spec/PushController.spec.js @@ -4,6 +4,12 @@ const StatusHandler = require('../lib/StatusHandler'); const Config = require('../lib/Config'); const validatePushType = require('../lib/Push/utils').validatePushType; +function sleep(ms) { + return new Promise(function (resolve) { + setTimeout(resolve, ms); + }); +} + const successfulTransmissions = function (body, installations) { const promises = installations.map(device => { return Promise.resolve({ @@ -31,6 +37,7 @@ const pushCompleted = async pushId => { query.equalTo('objectId', pushId); let result = await query.first({ useMasterKey: true }); while (!(result && result.get('status') === 'succeeded')) { + await sleep(1000); result = await query.first({ useMasterKey: true }); } };