Skip to content

Commit

Permalink
chore(test): simplify mergeMap test
Browse files Browse the repository at this point in the history
Remove the mapTo and the concat to reduce the number of subscribers to
make the test easier to reason with.
  • Loading branch information
cartant committed Sep 21, 2018
1 parent 4eb3f44 commit b817f53
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 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, mapTo } from 'rxjs/operators';
import { asapScheduler, concat, defer, Observable, from, of, timer } from 'rxjs';
import { mergeMap, map } from 'rxjs/operators';
import { asapScheduler, defer, Observable, from, of, timer } from 'rxjs';
import { hot, cold, expectObservable, expectSubscriptions } from '../helpers/marble-testing';

declare const type: Function;
Expand Down Expand Up @@ -772,18 +772,18 @@ describe('mergeMap', () => {
const results: (number | string)[] = [];

const wrapped = new Observable<number>(subscriber => {
const subscription = timer(0, asapScheduler).pipe(mapTo(42)).subscribe(subscriber);
const subscription = timer(0, asapScheduler).subscribe(subscriber);
return () => subscription.unsubscribe();
});
wrapped.pipe(
mergeMap(value => concat(of(value), timer(0, asapScheduler).pipe(mapTo(value))))
mergeMap(() => timer(0, asapScheduler))
).subscribe({
next(value) { results.push(value); },
complete() { results.push('done'); }
});

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

0 comments on commit b817f53

Please sign in to comment.