Skip to content

Commit

Permalink
test(expand): add test against breaking unsubscription chain
Browse files Browse the repository at this point in the history
For issue #875.
  • Loading branch information
staltz authored and kwonoj committed Dec 8, 2015
1 parent 4f02090 commit 425f44a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/operators/expand-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,34 @@ describe('Observable.prototype.expand()', function () {
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});

it('should not break unsubscription chains when result is unsubscribed explicitly', function () {
var values = {
a: 1,
b: 1 + 1, // a + a,
c: 2 + 2, // b + b,
d: 4 + 4, // c + c,
e: 8 + 8, // d + d
};
var e1 = hot('(a|)', values);
var e1subs = '^ ! ';
var e2shape = '---(z|) ';
var expected = 'a--b--c- ';
var unsub = ' ! ';

var result = e1
.mergeMap(function (x) { return Observable.of(x); })
.expand(function (x) {
if (x === 16) {
return Observable.empty();
}
return cold(e2shape, { z: x + x });
})
.mergeMap(function (x) { return Observable.of(x); });

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

it('should allow concurrent expansions', function () {
var values = {
a: 1,
Expand Down

0 comments on commit 425f44a

Please sign in to comment.