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

fix(ErrorObservable): Added and fixed failing test for Observable.catch #2552

Merged
merged 2 commits into from
May 17, 2017

Conversation

trshafer
Copy link
Contributor

@trshafer trshafer commented Apr 13, 2017

Description:

Added a failing test describing unexpected behavior between throw Error and Observable.throw(Error) when the source of an observable is a Promise. In my opinion this behavior is confusing as the catch handler needs to know if the source is from a Promise vs another source. Thanks for taking a look.

Added fix by forcing sync.syncErrorThrowable on ErrorObservable. Let me know if this is a good fix and if I should add a unit test for ErrorObservable.

Related issue (if exists):

Related #2485.

@trshafer trshafer force-pushed the observable-throw-from-promise branch 3 times, most recently from 49dae47 to a5e9c33 Compare April 13, 2017 23:01
@trshafer trshafer changed the title test(Observable.catch): Added failing test for Observable.catch fix(ErrorObservable): Added and fixed failing test for Observable.catch Apr 13, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 97.674% when pulling f9a64c6 on trshafer:observable-throw-from-promise into e387113 on ReactiveX:master.

@trshafer trshafer force-pushed the observable-throw-from-promise branch from f9a64c6 to 4e2a978 Compare April 14, 2017 00:05
@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 97.674% when pulling 4e2a978 on trshafer:observable-throw-from-promise into e387113 on ReactiveX:master.

let timers: sinon.SinonFakeTimers;

let source: Rx.Observable<any>;
beforeEach(() => {
Copy link
Member

Choose a reason for hiding this comment

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

These tests are a little too DRY for my liking. Prefer doing as much set up as possible in each test.

Also, I'll be honest, I'm not at all familar with sinon.sandbox. I'll need to research it to see if it's an approach we want to use. I presume it's some virtualized scheduling thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @benlesh, thanks for taking a look at this PR. I'll update the tests to be more explicit per test and get back to you. I used sinon.sandbox as I found other examples in the current test suite: https://github.com/ReactiveX/rxjs/search?utf8=%E2%9C%93&q=sinon.sandbox&type=

Copy link
Member

Choose a reason for hiding this comment

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

we have few cases of using it, but in general if it can be avoided try not to use it. except some obvious cases (like test scheduler), usually test for Rx can be written without sandbox.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the source observable from the setup block and into each test.

@trshafer trshafer force-pushed the observable-throw-from-promise branch from 4e2a978 to 0f4bb92 Compare May 3, 2017 18:21
@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 97.674% when pulling 0f4bb92 on trshafer:observable-throw-from-promise into 83ebe90 on ReactiveX:master.

Copy link
Member

@benlesh benlesh left a comment

Choose a reason for hiding this comment

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

Just want a response on given feedback

@@ -278,4 +279,83 @@ describe('Observable.prototype.catch', () => {
done();
});
});

context('fromPromise', () => {
Copy link
Member

Choose a reason for hiding this comment

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

I know this is a nitpick... but everywhere else I think we use describe. I didn't even know context is a thing. Is there a reason this is better in this case than describe?

Copy link
Contributor Author

@trshafer trshafer May 17, 2017

Choose a reason for hiding this comment

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

Happy to change it to describe, didn't realize there are no other usages of context in the test suite. I personally have used context to mean "a different approach to call the same feature" where describe is a "different feature". There is no difference in functionality.

describe('functionA', () => {
  context('success', () => {...});
  context('error', () => {...});
});

Documentation: https://mochajs.org/#bdd

Copy link
Member

Choose a reason for hiding this comment

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

it's fine I think.

@benlesh benlesh merged commit cf88a20 into ReactiveX:master May 17, 2017
@benlesh
Copy link
Member

benlesh commented May 17, 2017

Thanks, @trshafer!

@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants