From f5d035abbf12e3367dc29a08404e4d52a390229b Mon Sep 17 00:00:00 2001 From: Mateusz Podlasin Date: Tue, 21 Feb 2017 04:20:17 +0100 Subject: [PATCH] fix(concat): will now return Observable when given a single object implementing Symbol.observable (#2387) When static concat is called with single lower case observable, adapt it to RxJS Observable, so that operator would always return an Observable instance. --- spec/observables/concat-spec.ts | 17 +++++++++++++++++ src/operator/concat.ts | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/spec/observables/concat-spec.ts b/spec/observables/concat-spec.ts index f06e5d373a..4810df6328 100644 --- a/spec/observables/concat-spec.ts +++ b/spec/observables/concat-spec.ts @@ -1,5 +1,6 @@ import {expect} from 'chai'; import * as Rx from '../../dist/cjs/Rx'; +import {lowerCaseO} from '../helpers/test-helper'; import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports declare const hot: typeof marbleTestingSignature.hot; @@ -367,4 +368,20 @@ describe('Observable.concat', () => { expect(e1Subscribed).to.be.false; }); + + it('should return passed observable if no scheduler was passed', () => { + const source = cold('--a---b----c---|'); + const result = Observable.concat(source); + + expect(result).to.equal(source); + expectObservable(result).toBe('--a---b----c---|'); + }); + + it('should return RxJS Observable when single lowerCaseO was passed', () => { + const source = lowerCaseO('a', 'b', 'c'); + const result = Observable.concat(source); + + expect(result).to.be.an.instanceof(Observable); + expectObservable(result).toBe('(abc|)'); + }); }); diff --git a/src/operator/concat.ts b/src/operator/concat.ts index e835ba60fc..be5e43eade 100644 --- a/src/operator/concat.ts +++ b/src/operator/concat.ts @@ -135,7 +135,7 @@ export function concatStatic(...observables: Array | scheduler = args.pop(); } - if (scheduler === null && observables.length === 1) { + if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable) { return >observables[0]; }