Fix for #4194 - me no likey much (#4198)

* Adds failing test for #4194

* Use the rest module instad of the Parse._request

- Some users have an invalid serverUrl passed in the options

* removes console.logs, fixes tests that leveraged Parse._request
This commit is contained in:
Florent Vilmart
2017-09-22 12:05:06 -04:00
committed by GitHub
parent 70ca7bdd41
commit b703ec8a79
3 changed files with 96 additions and 52 deletions

View File

@@ -503,6 +503,62 @@ describe('PushController', () => {
.then(done).catch(done.fail);
});
it('properly creates _PushStatus without serverURL', (done) => {
const pushStatusAfterSave = {
handler: function() {}
};
Parse.Cloud.afterSave('_PushStatus', pushStatusAfterSave.handler);
const installation = new Parse.Object("_Installation");
installation.set("installationId", "installation");
installation.set("deviceToken","device_token")
installation.set("badge", 0);
installation.set("originalBadge", 0);
installation.set("deviceType", "ios");
var payload = {data: {
alert: "Hello World!",
badge: 1,
}}
var pushAdapter = {
send: function(body, installations) {
return successfulIOS(body, installations);
},
getValidPushTypes: function() {
return ["ios"];
}
}
var config = new Config(Parse.applicationId);
var auth = {
isMaster: true
}
var pushController = new PushController();
return installation.save().then(() => {
return reconfigureServer({
serverURL: 'http://localhost:8378/', // server with borked URL
push: { adapter: pushAdapter }
})
})
.then(() => {
return pushController.sendPush(payload, {}, config, auth);
}).then(() => {
// it is enqueued so it can take time
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, 1000);
});
}).then(() => {
Parse.serverURL = 'http://localhost:8378/1'; // GOOD url
const query = new Parse.Query('_PushStatus');
return query.find({useMasterKey: true});
}).then((results) => {
expect(results.length).toBe(1);
})
.then(done).catch(done.fail);
});
it('should properly report failures in _PushStatus', (done) => {
var pushAdapter = {
send: function(body, installations) {