Skip to content

Fix #494: Reject a promise on error condition #495

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

Merged
merged 1 commit into from
Jun 25, 2018

Conversation

nrchandan
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Oct 23, 2017

Codecov Report

Merging #495 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #495      +/-   ##
==========================================
+ Coverage   84.59%   84.59%   +<.01%     
==========================================
  Files          48       48              
  Lines        3952     3954       +2     
  Branches      897      897              
==========================================
+ Hits         3343     3345       +2     
  Misses        609      609
Impacted Files Coverage Δ
src/ParseObject.js 86.59% <100%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee33c48...1bc7d26. Read the comment docs.

@@ -1847,6 +1847,8 @@ var DefaultController = {
}, options);
}).then((response, status, xhr) => {
batchReturned.resolve(response, status);
}, (error) => {
batchReturned.reject(new _ParseError2.default(undefined, error.message));
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems wrong, should probably be new ParseError(error.message);

@nrchandan
Copy link
Contributor Author

nrchandan commented Oct 23, 2017 via email

@flovilmart
Copy link
Contributor

flovilmart commented Oct 23, 2017 via email

@nrchandan
Copy link
Contributor Author

Tried going through the tests in ParseObjectTest.js. Currently, there are no tests that cause failure of saveAll. I'm not sure how to make it fail.

@nrchandan
Copy link
Contributor Author

nrchandan commented Oct 23, 2017 via email

it('cannot set an invalid date', (done) => {
let obj = new TestObject();
obj.set('when', new Date(Date.parse(null)));
Parse.Object.saveAll([obj]).fail((e) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add .then(done.fail)

let obj = new TestObject();
obj.set('when', new Date(Date.parse(null)));
Parse.Object.saveAll([obj]).fail((e) => {
done();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please test for the expected error message.

@flovilmart
Copy link
Contributor

Also, the coverage is not improved as you’ve added an integration test and not a jest unit test. You may wanna consider doing that as there’s no way for now to ensure the code path is properly covered.

@nrchandan
Copy link
Contributor Author

nrchandan commented Oct 24, 2017 via email

@nrchandan
Copy link
Contributor Author

nrchandan commented Oct 24, 2017

Found two duplicate unit tests (both in the unit test file ParseObject-test.js):
can save an array of objects is repeated twice (no diff)
can save the object appears twice with a negligible difference (objectId: 'P1' vs objectId: 'P5')

Should I remove these two in the same PR, or would you recommend creating a new PR for this?

@nrchandan nrchandan force-pushed the resolve-promise branch 2 times, most recently from 8a6d78d to 8f695f1 Compare October 24, 2017 05:18
@flovilmart
Copy link
Contributor

I prefer we don’t remove unit tests, PR’s should be as atomic as possible.

@nrchandan
Copy link
Contributor Author

nrchandan commented Oct 24, 2017 via email

@nrchandan
Copy link
Contributor Author

Added a new error code:

/**
 * Error code indicating an invalid value of an object field is passed.
 * @property INVALID_VALUE
 * @static
 * @final
 */
ParseError.INVALID_VALUE = 603

Also, updated the tests to check for both error message and this new error code.

@nrchandan
Copy link
Contributor Author

Unit test has passed, but integration failed. Both the tests are very similar. @flovilmart Could you help me fix it, or would it make sense to remove it instead?

@nrchandan
Copy link
Contributor Author

Hi @flovilmart, I made a couple of changes. Could you take a look at this revised PR and let me know if this looks good for merging.

@flovilmart
Copy link
Contributor

This is looking good now! Let's go!

@flovilmart flovilmart merged commit dd20b4b into parse-community:master Jun 25, 2018
@nrchandan nrchandan deleted the resolve-promise branch August 24, 2020 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants