-
-
Notifications
You must be signed in to change notification settings - Fork 597
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
src/ParseObject.js
Outdated
@@ -1847,6 +1847,8 @@ var DefaultController = { | |||
}, options); | |||
}).then((response, status, xhr) => { | |||
batchReturned.resolve(response, status); | |||
}, (error) => { | |||
batchReturned.reject(new _ParseError2.default(undefined, error.message)); |
There was a problem hiding this comment.
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);
Thanks for pointing it out. Will correct and push shortly.
…On Oct 23, 2017 17:51, "Florent Vilmart" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/ParseObject.js
<#495 (comment)>
:
> @@ -1847,6 +1847,8 @@ var DefaultController = {
}, options);
}).then((response, status, xhr) => {
batchReturned.resolve(response, status);
+ }, (error) => {
+ batchReturned.reject(new _ParseError2.default(undefined, error.message));
this seems wrong, should probably be new ParseError(error.message);
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#495 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABYXzgPktVZjE9eOTIzTOvJHTaCKEYx8ks5svIS5gaJpZM4QCuR6>
.
|
Also consider adding tests as you are changing a public interface, and this may be unexpected for many users.
…On Oct 23, 2017, 08:29 -0400, Chandan Kumar ***@***.***>, wrote:
Thanks for pointing it out. Will correct and push shortly.
On Oct 23, 2017 17:51, "Florent Vilmart" ***@***.***> wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In src/ParseObject.js
> <#495 (comment)>
> :
>
> > @@ -1847,6 +1847,8 @@ var DefaultController = {
> }, options);
> }).then((response, status, xhr) => {
> batchReturned.resolve(response, status);
> + }, (error) => {
> + batchReturned.reject(new _ParseError2.default(undefined, error.message));
>
> this seems wrong, should probably be new ParseError(error.message);
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#495 (review)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABYXzgPktVZjE9eOTIzTOvJHTaCKEYx8ks5svIS5gaJpZM4QCuR6>
> .
>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
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. |
6b1deec
to
3f385d4
Compare
I think I can make it fail. Let me give it a try.
…On Oct 23, 2017 18:03, "Florent Vilmart" ***@***.***> wrote:
Also consider adding tests as you are changing a public interface, and
this may be unexpected for many users.
On Oct 23, 2017, 08:29 -0400, Chandan Kumar ***@***.***>,
wrote:
> Thanks for pointing it out. Will correct and push shortly.
>
> On Oct 23, 2017 17:51, "Florent Vilmart" ***@***.***>
wrote:
>
> > ***@***.**** commented on this pull request.
> > ------------------------------
> >
> > In src/ParseObject.js
> > <https://github.com/parse-community/Parse-SDK-JS/pull/
495#discussion_r146246771>
> > :
> >
> > > @@ -1847,6 +1847,8 @@ var DefaultController = {
> > }, options);
> > }).then((response, status, xhr) => {
> > batchReturned.resolve(response, status);
> > + }, (error) => {
> > + batchReturned.reject(new _ParseError2.default(undefined,
error.message));
> >
> > this seems wrong, should probably be new ParseError(error.message);
> >
> > —
> > You are receiving this because you authored the thread.
> > Reply to this email directly, view it on GitHub
> > <https://github.com/parse-community/Parse-SDK-JS/pull/
495#pullrequestreview-71159792>,
> > or mute the thread
> > <https://github.com/notifications/unsubscribe-auth/
ABYXzgPktVZjE9eOTIzTOvJHTaCKEYx8ks5svIS5gaJpZM4QCuR6>
> > .
> >
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub, or mute the thread.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#495 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABYXzju05NnnBPnCVwiv5IHIjH4SZgkAks5svIeYgaJpZM4QCuR6>
.
|
3f385d4
to
d4c570c
Compare
integration/test/ParseObjectTest.js
Outdated
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) => { |
There was a problem hiding this comment.
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)
integration/test/ParseObjectTest.js
Outdated
let obj = new TestObject(); | ||
obj.set('when', new Date(Date.parse(null))); | ||
Parse.Object.saveAll([obj]).fail((e) => { | ||
done(); |
There was a problem hiding this comment.
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.
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. |
That makes sense. Let me try adding a unit test.
…On Oct 24, 2017 6:40 AM, "Florent Vilmart" ***@***.***> wrote:
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.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#495 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABYXzkQ7fDhrJg42-bUJe1GOMY3dPSxLks5svTj7gaJpZM4QCuR6>
.
|
Found two duplicate unit tests (both in the unit test file Should I remove these two in the same PR, or would you recommend creating a new PR for this? |
8a6d78d
to
8f695f1
Compare
I prefer we don’t remove unit tests, PR’s should be as atomic as possible. |
Thanks Florent. Let me undo that and push again.
…On Tue, Oct 24, 2017 at 5:01 PM, Florent Vilmart ***@***.***> wrote:
I prefer we don’t remove unit tests, PR’s should be as atomic as possible.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#495 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABYXzlkmLxMjAPYIx06a6lbqqv9Sswb7ks5svcp6gaJpZM4QCuR6>
.
|
8f695f1
to
c07018c
Compare
Added a new error code:
Also, updated the tests to check for both error message and this new error code. |
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? |
c07018c
to
1bc7d26
Compare
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. |
This is looking good now! Let's go! |
No description provided.