Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added PromiseWithoutRejectedCallbackFail #479

Closed
wants to merge 3 commits into from
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);
});
});