-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Re-fix isObservable() and add test - fixes #29 #30
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
const isListr = obj => obj && obj.setRenderer && obj.add && obj.run; | ||
// https://github.com/sindresorhus/is-observable/issues/1 | ||
const isObservable = obj => obj && typeof obj.subscribe === 'function' && obj.constructor.name === 'Observable'; | ||
|
||
exports.isListr = isListr; | ||
exports.isObservable = isObservable; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import test from 'ava'; | ||
import {Observable as RxObservable} from 'rxjs/Observable'; | ||
import ZenObservable from 'zen-observable'; | ||
import Listr from '../'; | ||
import {isListr, isObservable} from '../lib/util'; | ||
|
||
test('isListr', t => { | ||
t.falsy(isListr(null)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initially I did. But it failed, since right now Any suggestions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrap it in |
||
t.falsy(isListr({})); | ||
t.falsy(isListr(() => {})); | ||
t.truthy(isListr(new Listr([]))); | ||
}); | ||
|
||
test('isObservable', t => { | ||
t.falsy(isObservable(null)); | ||
t.falsy(isObservable({})); | ||
t.falsy(isObservable(new Listr([]))); | ||
t.falsy(isObservable(new Promise(() => {}))); | ||
t.truthy(isObservable(new RxObservable(() => {}))); | ||
t.truthy(isObservable(new ZenObservable(() => {}))); | ||
}); |
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.
Export the function right away without intermediate step.