Skip to content

Commit

Permalink
chore(test): reorder test cases
Browse files Browse the repository at this point in the history
relates to #1460
  • Loading branch information
kwonoj committed Mar 23, 2016
1 parent 4312d97 commit dd461e4
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion spec/operators/publishReplay-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -390,4 +418,4 @@ describe('Observable.prototype.publishReplay', () => {

expect(results).toEqual([4]);
});
});
});

0 comments on commit dd461e4

Please sign in to comment.