From e0f55dea84d5c70aaf2cf401482e957d59389426 Mon Sep 17 00:00:00 2001 From: Thiago Figueredo Cardoso Date: Mon, 7 Dec 2015 18:40:08 -0300 Subject: [PATCH] test(single): add test against breaking unsubscription chain Relates to #875. --- spec/operators/single-spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/operators/single-spec.js b/spec/operators/single-spec.js index 42eb583303..e0496901df 100644 --- a/spec/operators/single-spec.js +++ b/spec/operators/single-spec.js @@ -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 () { @@ -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); + }); }); \ No newline at end of file