Skip to content

Commit

Permalink
test(groupBy): add test against breaking unsubscription chain
Browse files Browse the repository at this point in the history
Add test for groupBy() operator, to verify that unsubscription chains are not broken when the
observable is unsubscribed explicitly.

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

it('should not break unsubscription chain when unsubscribed explicitly', function () {
var values = {
a: ' foo',
b: ' FoO ',
c: 'baR ',
d: 'foO ',
e: ' Baz ',
f: ' qux ',
g: ' bar',
h: ' BAR ',
i: 'FOO ',
j: 'baz ',
k: ' bAZ ',
l: ' fOo '
};
var e1 = hot('-1--2--^-a-b-c-d-e-f-g-h-i-j-k-l-|', values);
var e1subs = '^ !';
var expected = '--w---x---y-';
var unsub = ' !';
var expectedValues = { w: 'foo', x: 'bar', y: 'baz' };

var source = e1
.mergeMap(function (x) { return Observable.of(x); })
.groupBy(function (x) { return x.toLowerCase().trim(); })
.mergeMap(function (group) { return Observable.of(group.key); });

expectObservable(source, unsub).toBe(expected, expectedValues);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});

it('should group values with a keySelector which eventually throws', function () {
var values = {
a: ' foo',
Expand Down

0 comments on commit dcbf0f0

Please sign in to comment.