Files
angular/packages/core/test/util/lang_spec.ts
Matthieu Riegler daaf0fd2f6 refactor(core): Remove isObservable() in favor isSubscribable(). (#49295)
The private util `isObservable` was actually just testing the same thing as`isSubscribable()`. As the implementation is closer to the function's name, let's only keep ``isSubscribable`.

PR Close #49295
2023-03-08 17:58:19 +00:00

28 lines
1016 B
TypeScript

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* 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 {isSubscribable} from '@angular/core/src/util/lang';
import {of} from 'rxjs';
describe('isSubscribable', () => {
it('should be true for an Observable', () => expect(isSubscribable(of(true))).toEqual(true));
it('should be true if the argument is the object with subscribe function',
() => expect(isSubscribable({subscribe: () => {}})).toEqual(true));
it('should be false if the argument is undefined',
() => expect(isSubscribable(undefined)).toEqual(false));
it('should be false if the argument is null', () => expect(isSubscribable(null)).toEqual(false));
it('should be false if the argument is an object',
() => expect(isSubscribable({})).toEqual(false));
it('should be false if the argument is a function',
() => expect(isSubscribable(() => {})).toEqual(false));
});