Skip to content

Commit

Permalink
test(single): add test against breaking unsubscription chain
Browse files Browse the repository at this point in the history
Relates to ReactiveX#875.
  • Loading branch information
figueredo committed Dec 7, 2015
1 parent d5adbd4 commit 977acec
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/operators/single-spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* globals describe, it, expect, expectObservable, expectSubscriptions, hot, cold */
var Rx = require('../../dist/cjs/Rx');
var Observable = Rx.Observable;

describe('Observable.prototype.single()', function () {
it('should raise error from empty predicate if observable does not emit', function () {
Expand Down Expand Up @@ -128,4 +129,19 @@ describe('Observable.prototype.single()', function () {
expectObservable(e1.single(predicate)).toBe(expected, {z: undefined});
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});

it('should not break unsubscription chain when unsubscribed explicitly', function () {
var e1 = hot('--a--b--c--|');
var unsub = ' ! ';
var e1subs = '^ ! ';
var expected = '---- ';

var result = e1
.mergeMap(function(x) { return Observable.of(x); })
.single()
.mergeMap(function(x) { return Observable.of(x); });

expectObservable(result, unsub).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});
});

0 comments on commit 977acec

Please sign in to comment.