From 52ac86c83258a2ce855431c0cc0a0e659698b4fd Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Sat, 5 Dec 2015 14:07:53 +0200 Subject: [PATCH] test(retryWhen): add test against breaking unsubscription chain Add test for retryWhen() operator to verify that unsubscription chains are not broken when unsubscribe happens. For issue #875. --- spec/operators/retryWhen-spec.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/operators/retryWhen-spec.js b/spec/operators/retryWhen-spec.js index 1aaade07cd..73db39f8a4 100644 --- a/spec/operators/retryWhen-spec.js +++ b/spec/operators/retryWhen-spec.js @@ -249,6 +249,26 @@ describe('Observable.prototype.retryWhen()', function () { expectSubscriptions(notifier.subscriptions).toBe(nsubs); }); + it('should not break unsubscription chains when unsubscribed explicitly', function () { + var source = cold( '-1--2--#'); + var subs = ['^ ! ', + ' ^ ! ', + ' ^ ! ']; + var notifier = hot('---------r-------r-------r-#'); + var nsubs = ' ^ ! '; + var expected = '-1--2-----1--2----1-- '; + var unsub = ' ! '; + + var result = source + .mergeMap(function (x) { return Observable.of(x); }) + .retryWhen(function (errors) { return notifier; }) + .mergeMap(function (x) { return Observable.of(x); }); + + expectObservable(result, unsub).toBe(expected); + expectSubscriptions(source.subscriptions).toBe(subs); + expectSubscriptions(notifier.subscriptions).toBe(nsubs); + }); + it('should handle a source with eventual error using a dynamic notifier ' + 'selector which eventually throws', function () { var source = cold('-1--2--#');