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(isObservable): Fix throwing error when testing isObservable(null) #3688

Merged
merged 3 commits into from
May 21, 2018

Conversation

bbonnet
Copy link
Contributor

@bbonnet bbonnet commented May 11, 2018

Description:
Fix isObservable to test to make sure the test subject is a function or object before attempting to access properties on it.

Related issue (if exists):
#3687

@coveralls
Copy link

coveralls commented May 11, 2018

Coverage Status

Coverage decreased (-0.2%) to 96.629% when pulling f866d24 on bbonnet:fix-isObservable into dc66731 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.

This isn't quite right. We don't need to check to see if it's a function or object, we just needed to group the checks after the "falsiness" check.

return obj && (obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'))

@bbonnet
Copy link
Contributor Author

bbonnet commented May 15, 2018

@benlesh Above suggestion gave me AssertionError: expected null to be false for the isObservable(null) case so added !!obj for coercion to boolean

@@ -1,10 +1,12 @@
import { Observable } from '../Observable';
import { ObservableInput } from '../types';
import { isObject } from './isObject';
import { isFunction } from './isFunction';
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unused imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, updated.

@benlesh benlesh merged commit c9acc61 into ReactiveX:master May 21, 2018
@benlesh
Copy link
Member

benlesh commented May 21, 2018

thanks @bbonnet!

@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 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