Skip to content

Commit 505f5b7

Browse files
committed
fix(test): make explicit unsubscription for observable
1 parent 836b140 commit 505f5b7

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

spec/observables/fromEvent-spec.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ describe('Observable.fromEvent', function () {
9494
}
9595
};
9696

97-
var subscription = Observable.fromEvent(obj, 'click')
97+
Observable.fromEvent(obj, 'click').take(1)
9898
.subscribe(function (e) {
9999
expect(e).toBe('test');
100-
done();
101-
});
100+
}, function (err) {
101+
done.fail('should not be called');
102+
}, done);
102103

103104
send('test');
104105
});
@@ -117,11 +118,12 @@ describe('Observable.fromEvent', function () {
117118
return x + '!';
118119
}
119120

120-
var subscription = Observable.fromEvent(obj, 'click', selector)
121+
Observable.fromEvent(obj, 'click', selector).take(1)
121122
.subscribe(function (e) {
122123
expect(e).toBe('test!');
123-
done();
124-
});
124+
}, function (err) {
125+
done.fail('should not be called');
126+
}, done);
125127

126128
send('test');
127129
});

spec/operators/bufferWhen-spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,17 @@ describe('Observable.prototype.bufferWhen', function () {
230230
var closing = Observable.empty();
231231
var TOO_MANY_INVOCATIONS = 30;
232232

233-
var invoked = 0;
234233
source
235234
.bufferWhen(function () { return closing; })
235+
.takeWhile(function (val, index) {
236+
return index < TOO_MANY_INVOCATIONS;
237+
})
236238
.subscribe(function (val) {
237239
expect(Array.isArray(val)).toBe(true);
238240
expect(val.length).toBe(0);
239-
invoked++;
240-
if (invoked > TOO_MANY_INVOCATIONS) {
241-
done();
242-
}
243-
}, null, null);
241+
}, function (err) {
242+
done.fail('should not be called');
243+
}, done);
244244
});
245245

246246
it('should handle inner throw', function () {

0 commit comments

Comments
 (0)