Skip to content

Commit

Permalink
test(mergeMap): add failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cartant committed Aug 31, 2018
1 parent 73bfa92 commit d389e13
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 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 { Observable, from, of } from 'rxjs';
import { delay, mergeMap, map } from 'rxjs/operators';
import { defer, Observable, from, of } from 'rxjs';
import { hot, cold, expectObservable, expectSubscriptions } from '../helpers/marble-testing';

declare const type: Function;
Expand Down Expand Up @@ -712,6 +712,58 @@ describe('mergeMap', () => {
expect(completed).to.be.true;
});

it('should support nested merges', (done: any) => {

// Added as a failing test when investigating:
// https://github.com/ReactiveX/rxjs/issues/4071

const results: any[] = [];

of(1).pipe(
mergeMap(() => defer(() =>
of(2).pipe(delay(0))
).pipe(
mergeMap(() => defer(() =>
of(3).pipe(delay(0))
))
))
)
.subscribe({
next(value: any) { results.push(value); },
complete() { results.push('done'); }
});

setTimeout(() => {
expect(results).to.deep.equal([3, 'done']);
done();
}, 10);
});

it('should support nested merges with promises', (done: any) => {

// Added as a failing test when investigating:
// https://github.com/ReactiveX/rxjs/issues/4071

const results: any[] = [];

of(1).pipe(
mergeMap(() =>
from(Promise.resolve(2)).pipe(
mergeMap(() => Promise.resolve(3))
)
)
)
.subscribe({
next(value) { results.push(value); },
complete() { results.push('done'); }
});

setTimeout(() => {
expect(results).to.deep.equal([3, 'done']);
done();
}, 0);
});

type('should support type signatures', () => {
let o: Observable<number>;

Expand Down

0 comments on commit d389e13

Please sign in to comment.