From 5d92a9be54791207b9641e0821c71495077f2412 Mon Sep 17 00:00:00 2001 From: Nicholas Jamieson Date: Thu, 6 Sep 2018 23:22:35 +1000 Subject: [PATCH] test(mergeMap): add failing test --- spec/operators/mergeMap-spec.ts | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/spec/operators/mergeMap-spec.ts b/spec/operators/mergeMap-spec.ts index 05ca08168a7..5af05847dea 100644 --- a/spec/operators/mergeMap-spec.ts +++ b/spec/operators/mergeMap-spec.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { mergeMap, map } from 'rxjs/operators'; -import { asapScheduler, defer, Observable, from, of } from 'rxjs'; +import { mergeMap, map, mapTo } from 'rxjs/operators'; +import { asapScheduler, concat, defer, Observable, from, of, timer } from 'rxjs'; import { hot, cold, expectObservable, expectSubscriptions } from '../helpers/marble-testing'; declare const type: Function; @@ -717,7 +717,7 @@ describe('mergeMap', () => { // Added as a failing test when investigating: // https://github.com/ReactiveX/rxjs/issues/4071 - const results: any[] = []; + const results: (number | string)[] = []; of(1).pipe( mergeMap(() => defer(() => @@ -744,7 +744,7 @@ describe('mergeMap', () => { // Added as a failing test when investigating: // https://github.com/ReactiveX/rxjs/issues/4071 - const results: any[] = []; + const results: (number | string)[] = []; of(1).pipe( mergeMap(() => @@ -764,6 +764,30 @@ describe('mergeMap', () => { }, 0); }); + it('should support wrapped sources', (done: MochaDone) => { + + // Added as a failing test when investigating: + // https://github.com/ReactiveX/rxjs/issues/4095 + + const results: (number | string)[] = []; + + const wrapped = new Observable(subscriber => { + const subscription = timer(0, asapScheduler).pipe(mapTo(42)).subscribe(subscriber); + return () => subscription.unsubscribe(); + }); + wrapped.pipe( + mergeMap(value => concat(of(value), timer(0, asapScheduler).pipe(mapTo(value)))) + ).subscribe({ + next(value) { results.push(value); }, + complete() { results.push('done'); } + }); + + setTimeout(() => { + expect(results).to.deep.equal([42, 42, 'done']); + done(); + }, 0); + }); + type('should support type signatures', () => { let o: Observable;