Skip to content

Commit

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

For issue ReactiveX#875.
  • Loading branch information
staltz committed Dec 5, 2015
1 parent f1dc764 commit bf65af0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/operators/repeat-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ describe('Observable.prototype.repeat()', function () {
expectSubscriptions(e1.subscriptions).toBe(subs);
});

it('should not break unsubscription chain when unsubscribed explicitly', function () {
var e1 = cold('--a--b--| ');
var subs = ['^ ! ',
' ^ ! ',
' ^ ! ',
' ^ ! ',
' ^ ! ',
' ^ !'];
var unsub = ' !';
var expected = '--a--b----a--b----a--b----a--b----a--b----a--';

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

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

it('should consider negative count as repeat indefinitely', function () {
var e1 = cold('--a--b--| ');
var subs = ['^ ! ',
Expand Down

0 comments on commit bf65af0

Please sign in to comment.