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 fa09888 commit ecd99ed
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 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]);
});
});
14 changes: 7 additions & 7 deletions src/operator/bufferToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ import {InnerSubscriber} from '../InnerSubscriber';
*
* @param {Observable<O>} openings An observable of notifications to start new
* buffers.
* @param {function(value: O): Observable} closingSelector A function that takes
* the value emitted by the `openings` observable and returns an Observable,
* which, when it emits, signals that the associated buffer should be emitted
* and cleared.
* @param {function(value: O): SubscribableOrPromise} closingSelector A function
* that takes the value emitted by the `openings` observable and returns
* a 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
* @owner Observable
Expand Down Expand Up @@ -157,13 +157,13 @@ class BufferToggleSubscriber<T, O> extends OuterSubscriber<T, O> {

const innerSubscription = subscribeToResult(this, closingNotifier, <any>context);

if (!innerSubscription.isUnsubscribed) {
if (innerSubscription.isUnsubscribed) {
this.closeBuffer(context);
} else {
(<any> innerSubscription).context = context;

this.add(innerSubscription);
subscription.add(innerSubscription);
} else {
this.closeBuffer(context);
}
}
}
Expand Down

0 comments on commit ecd99ed

Please sign in to comment.