|
1 | 1 | import { expect } from 'chai';
|
2 | 2 | import * as sinon from 'sinon';
|
3 | 3 | import { hot, cold, expectObservable, expectSubscriptions } from '../helpers/marble-testing';
|
4 |
| -import { shareReplay, mergeMapTo, retry, take } from 'rxjs/operators'; |
| 4 | +import { shareReplay, mergeMapTo, retry } from 'rxjs/operators'; |
5 | 5 | import { TestScheduler } from 'rxjs/testing';
|
6 |
| -import { Observable, interval, Operator, Observer, of } from 'rxjs'; |
| 6 | +import { Observable, Operator, Observer, of, from } from 'rxjs'; |
7 | 7 |
|
8 | 8 | declare function asDiagram(arg: string): Function;
|
9 | 9 | declare const rxTestScheduler: TestScheduler;
|
@@ -243,4 +243,23 @@ describe('shareReplay operator', () => {
|
243 | 243 | done();
|
244 | 244 | });
|
245 | 245 | });
|
| 246 | + |
| 247 | + it('should not skip values on a sync source', () => { |
| 248 | + const a = from(['a', 'b', 'c', 'd']); |
| 249 | + // We would like for the previous line to read like this: |
| 250 | + // |
| 251 | + // const a = cold('(abcd|)'); |
| 252 | + // |
| 253 | + // However, that would synchronously emit multiple values at frame 0, |
| 254 | + // but it's not synchronous upon-subscription. |
| 255 | + // TODO: revisit once https://github.com/ReactiveX/rxjs/issues/5523 is fixed |
| 256 | + |
| 257 | + const x = cold( 'x-------x'); |
| 258 | + const expected = '(abcd)--d'; |
| 259 | + |
| 260 | + const shared = a.pipe(shareReplay(1)); |
| 261 | + const result = x.pipe(mergeMapTo(shared)); |
| 262 | + expectObservable(result).toBe(expected); |
| 263 | + }); |
| 264 | + |
246 | 265 | });
|
0 commit comments