Skip to content

Commit

Permalink
fix(test): make explicit unsubscription for observable
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Nov 19, 2015
1 parent 836b140 commit 505f5b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 8 additions & 6 deletions spec/observables/fromEvent-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ describe('Observable.fromEvent', function () {
}
};

var subscription = Observable.fromEvent(obj, 'click')
Observable.fromEvent(obj, 'click').take(1)
.subscribe(function (e) {
expect(e).toBe('test');
done();
});
}, function (err) {
done.fail('should not be called');
}, done);

send('test');
});
Expand All @@ -117,11 +118,12 @@ describe('Observable.fromEvent', function () {
return x + '!';
}

var subscription = Observable.fromEvent(obj, 'click', selector)
Observable.fromEvent(obj, 'click', selector).take(1)
.subscribe(function (e) {
expect(e).toBe('test!');
done();
});
}, function (err) {
done.fail('should not be called');
}, done);

send('test');
});
Expand Down
12 changes: 6 additions & 6 deletions spec/operators/bufferWhen-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,17 @@ describe('Observable.prototype.bufferWhen', function () {
var closing = Observable.empty();
var TOO_MANY_INVOCATIONS = 30;

var invoked = 0;
source
.bufferWhen(function () { return closing; })
.takeWhile(function (val, index) {
return index < TOO_MANY_INVOCATIONS;
})
.subscribe(function (val) {
expect(Array.isArray(val)).toBe(true);
expect(val.length).toBe(0);
invoked++;
if (invoked > TOO_MANY_INVOCATIONS) {
done();
}
}, null, null);
}, function (err) {
done.fail('should not be called');
}, done);
});

it('should handle inner throw', function () {
Expand Down

0 comments on commit 505f5b7

Please sign in to comment.