Skip to content

Commit

Permalink
fix push tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dplewis committed Mar 13, 2021
1 parent f7bb165 commit 05aba62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/Parse.Push.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
};
Expand Down
7 changes: 7 additions & 0 deletions spec/PushController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 });
}
};
Expand Down

0 comments on commit 05aba62

Please sign in to comment.