Skip to content

Commit

Permalink
test(mergeMap): add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Sep 6, 2018
1 parent e3911bc commit 5d92a9b
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions spec/operators/mergeMap-spec.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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(() =>
Expand All @@ -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(() =>
Expand All @@ -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<number>(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<number>;

Expand Down

0 comments on commit 5d92a9b

Please sign in to comment.