From dd461e491895e76317d414301833ac8564d558bd Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Sat, 19 Mar 2016 10:53:50 -0700 Subject: [PATCH] chore(test): reorder test cases relates to #1460 --- spec/operators/publishReplay-spec.ts | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/spec/operators/publishReplay-spec.ts b/spec/operators/publishReplay-spec.ts index ba67481c202..1c37601f528 100644 --- a/spec/operators/publishReplay-spec.ts +++ b/spec/operators/publishReplay-spec.ts @@ -23,6 +23,34 @@ describe('Observable.prototype.publishReplay', () => { expect(source instanceof Rx.ConnectableObservable).toBe(true); }); + it('should follow the RxJS 4 behavior and NOT allow you to reconnect by subscribing again', (done: DoneSignature) => { + const expected = [1, 2, 3, 4]; + let i = 0; + + const source = Observable.of(1, 2, 3, 4).publishReplay(1); + + const results = []; + + source.subscribe( + (x: number) => { + expect(x).toBe(expected[i++]); + }, + done.fail, + () => { + i = 0; + + source.subscribe((x: number) => { + results.push(x); + }, done.fail, done); + + source.connect(); + }); + + source.connect(); + + expect(results).toEqual([4]); + }); + it('should do nothing if connect is not called, despite subscriptions', () => { const source = cold('--1-2---3-4--5-|'); const sourceSubs = []; @@ -390,4 +418,4 @@ describe('Observable.prototype.publishReplay', () => { expect(results).toEqual([4]); }); -}); \ No newline at end of file +});