Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions spec/ParseAPI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,4 +732,14 @@ describe('miscellaneous', function() {
});
});

it('fetches the config using a promise', done => {
Parse.Cloud.run('PromiseWithoutRejectedCallbackFail').then((s) => {
expect(s instanceof Object).toBe(true);
expect(s.config instanceof Object).toBe(true);
done();
}, (e) => {
fail(e);
});
});

});
17 changes: 17 additions & 0 deletions src/cloud/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,20 @@ Parse.Cloud.define('requiredParameterCheck', function(req, res) {
}, function(params) {
return params.name;
});

Parse.Cloud.define("PromiseWithoutRejectedCallbackFail", function(request, response) {
var promises = [];
var result = {};

// fetch config
result.config = {};

promises.push(Parse.Config.get().then(function(config) {
result.config = config.attributes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you add return Parse.Promise.as() there, does it changes any thing?

Can you add a Unit test as well so the failure is properly handled and we ensure no regression in the future?

}));

// wait for all promises to finish
Parse.Promise.when(promises).then(function() {
response.success(result);
});
});