fix(common): introduce isObservable method (#14067)
Closes #8848 PR Close #14067
This commit is contained in:

committed by
Miško Hevery

parent
fe441186e7
commit
ff290af38c
@ -5,7 +5,8 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {isPromise} from '@angular/core/src/util/lang';
|
||||
import {isObservable, isPromise} from '@angular/core/src/util/lang';
|
||||
import {of } from 'rxjs/observable/of';
|
||||
|
||||
export function main() {
|
||||
describe('isPromise', () => {
|
||||
@ -25,4 +26,22 @@ export function main() {
|
||||
expect(isPromise(null)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isObservable', () => {
|
||||
it('should be true for an Observable', () => expect(isObservable(of (true))).toEqual(true));
|
||||
|
||||
it('should be false if the argument is undefined',
|
||||
() => expect(isObservable(undefined)).toEqual(false));
|
||||
|
||||
it('should be false if the argument is null', () => expect(isObservable(null)).toEqual(false));
|
||||
|
||||
it('should be false if the argument is an object',
|
||||
() => expect(isObservable({})).toEqual(false));
|
||||
|
||||
it('should be false if the argument is a function',
|
||||
() => expect(isObservable(() => {})).toEqual(false));
|
||||
|
||||
it('should be false if the argument is the object with subscribe function',
|
||||
() => expect(isObservable({subscribe: () => {}})).toEqual(false));
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user