Skip to content

Commit 9f80210

Browse files
authored
Merge branch 'alpha' into cleanPostgres
2 parents fdaeeb0 + 7af5de4 commit 9f80210

File tree

1 file changed

+24
-50
lines changed

1 file changed

+24
-50
lines changed

spec/PushController.spec.js

+24-50
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,7 @@ describe('PushController', () => {
562562
});
563563
const pushStatusId = await sendPush(payload, {}, config, auth);
564564
// it is enqueued so it can take time
565-
await new Promise(resolve => {
566-
setTimeout(() => {
567-
resolve();
568-
}, 1000);
569-
});
565+
await sleep(1000);
570566
Parse.serverURL = 'http://localhost:8378/1'; // GOOD url
571567
const result = await Parse.Push.getPushStatus(pushStatusId);
572568
expect(result).toBeDefined();
@@ -767,7 +763,7 @@ describe('PushController', () => {
767763
});
768764
});
769765

770-
it('should not schedule push when not configured', done => {
766+
it('should not schedule push when not configured', async () => {
771767
const config = Config.get(Parse.applicationId);
772768
const auth = {
773769
isMaster: true,
@@ -800,33 +796,20 @@ describe('PushController', () => {
800796
installations.push(installation);
801797
}
802798

803-
reconfigureServer({
799+
await reconfigureServer({
804800
push: { adapter: pushAdapter },
805-
})
806-
.then(() => {
807-
return Parse.Object.saveAll(installations)
808-
.then(() => {
809-
return pushController.sendPush(payload, {}, config, auth);
810-
})
811-
.then(() => new Promise(resolve => setTimeout(resolve, 300)));
812-
})
813-
.then(() => {
814-
const query = new Parse.Query('_PushStatus');
815-
return query.find({ useMasterKey: true }).then(results => {
816-
expect(results.length).toBe(1);
817-
const pushStatus = results[0];
818-
expect(pushStatus.get('status')).not.toBe('scheduled');
819-
done();
820-
});
821-
})
822-
.catch(err => {
823-
console.error(err);
824-
fail('should not fail');
825-
done();
826-
});
801+
});
802+
await Parse.Object.saveAll(installations);
803+
await pushController.sendPush(payload, {}, config, auth);
804+
await sleep(1000);
805+
const query = new Parse.Query('_PushStatus');
806+
const results = await query.find({ useMasterKey: true });
807+
expect(results.length).toBe(1);
808+
const pushStatus = results[0];
809+
expect(pushStatus.get('status')).not.toBe('scheduled');
827810
});
828811

829-
it('should schedule push when configured', done => {
812+
it('should schedule push when configured', async () => {
830813
const auth = {
831814
isMaster: true,
832815
};
@@ -866,28 +849,19 @@ describe('PushController', () => {
866849
installation.set('deviceType', 'ios');
867850
installations.push(installation);
868851
}
869-
reconfigureServer({
852+
await reconfigureServer({
870853
push: { adapter: pushAdapter },
871854
scheduledPush: true,
872-
})
873-
.then(() => {
874-
const config = Config.get(Parse.applicationId);
875-
return Parse.Object.saveAll(installations)
876-
.then(() => {
877-
return pushController.sendPush(payload, {}, config, auth);
878-
})
879-
.then(() => new Promise(resolve => setTimeout(resolve, 300)));
880-
})
881-
.then(() => {
882-
const query = new Parse.Query('_PushStatus');
883-
return query.find({ useMasterKey: true }).then(results => {
884-
expect(results.length).toBe(1);
885-
const pushStatus = results[0];
886-
expect(pushStatus.get('status')).toBe('scheduled');
887-
});
888-
})
889-
.then(done)
890-
.catch(done.err);
855+
});
856+
const config = Config.get(Parse.applicationId);
857+
await Parse.Object.saveAll(installations);
858+
await pushController.sendPush(payload, {}, config, auth);
859+
await sleep(1000);
860+
const query = new Parse.Query('_PushStatus');
861+
const results = await query.find({ useMasterKey: true });
862+
expect(results.length).toBe(1);
863+
const pushStatus = results[0];
864+
expect(pushStatus.get('status')).toBe('scheduled');
891865
});
892866

893867
it('should not enqueue push when device token is not set', async () => {

0 commit comments

Comments
 (0)