Skip to content

Commit

Permalink
test(retryWhen): add test against breaking unsubscription chain
Browse files Browse the repository at this point in the history
Add test for retryWhen() operator to verify that unsubscription chains are not broken when
unsubscribe happens.

For issue #875.
  • Loading branch information
staltz authored and benlesh committed Dec 8, 2015
1 parent 078f124 commit 52ac86c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/operators/retryWhen-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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--#');
Expand Down

0 comments on commit 52ac86c

Please sign in to comment.