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 21, 2016
1 parent 0c390f2 commit 3f5a0fe
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions spec/operators/bufferToggle-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ describe('Observable.prototype.bufferToggle', () => {
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});

it('should accept closing selector returns promise resolves', (done: DoneSignature) => {
it('should accept closing selector that returns a resolved promise', (done: DoneSignature) => {
const e1 = Observable.concat(Observable.of(1),
Observable.timer(10).mapTo(2),
Observable.timer(10).mapTo(3),
Expand All @@ -361,7 +361,7 @@ describe('Observable.prototype.bufferToggle', () => {
});
});

it('should accept closing selector returns promise rejects', (done: DoneSignature) => {
it('should accept closing selector that returns a rejected promise', (done: DoneSignature) => {
const e1 = Observable.concat(Observable.of(1),
Observable.timer(10).mapTo(2),
Observable.timer(10).mapTo(3),
Expand Down
56 changes: 28 additions & 28 deletions 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 @@ -356,32 +384,4 @@ describe('Observable.prototype.publishReplay', () => {

published.connect();
});

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]);
});
});
2 changes: 1 addition & 1 deletion src/operator/bufferToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {InnerSubscriber} from '../InnerSubscriber';
* @param {Observable<O>} openings An observable of notifications to start new
* buffers.
* @param {Function} closingSelector a function that takes the value emitted by
* the `openings` observable and returns an Observable, which, when it emits,
* the `openings` observable and returns an Subscribable or Promise, which, when it emits,
* signals that the associated buffer should be emitted and cleared.
* @return {Observable<T[]>} an observable of arrays of buffered values.
* @method bufferToggle
Expand Down

0 comments on commit 3f5a0fe

Please sign in to comment.