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 Dec 12, 2015
1 parent fc3dcf7 commit 7f67b09
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
14 changes: 9 additions & 5 deletions spec/observables/fromEventPattern-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ describe('Observable.fromEventPattern', function () {
return a + b + '!';
};

Observable.fromEventPattern(addHandler, removeHandler, selector)
Observable.fromEventPattern(addHandler, removeHandler, selector).take(1)
.subscribe(function (x) {
expect(x).toBe('testme!');
done();
});
}, function (e) {
done.fail('should not be called');
}, done);

trigger('test', 'me');
});
Expand All @@ -89,10 +90,13 @@ describe('Observable.fromEventPattern', function () {
};

Observable.fromEventPattern(addHandler, removeHandler, selector)
.subscribe(function () { },
function (err) {
.subscribe(function (x) {
done.fail('should not be called');
}, function (err) {
expect(err).toBe('bad');
done();
}, function () {
done.fail('should not be called');
});

trigger('test');
Expand Down
5 changes: 3 additions & 2 deletions spec/observables/of-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ describe('Observable.of', function () {
Observable.of(42).subscribe(function (x) {
expect(++calls).toBe(1);
expect(x).toBe(42);
done();
});
}, function (x) {
done.fail('should not be called');
}, done);
});

it('should handle an Observable as the only value', function () {
Expand Down
6 changes: 4 additions & 2 deletions spec/observables/range-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Observable.range', function () {
expect(results).toEqual([12, 13, 14, 15]);
});

it('should accept a scheduler' , function (done) {
it('should accept a scheduler', function (done) {
var expected = [12, 13, 14, 15];
spyOn(asap, 'schedule').and.callThrough();

Expand All @@ -24,7 +24,9 @@ describe('Observable.range', function () {
expect(asap.schedule).toHaveBeenCalled();
var exp = expected.shift();
expect(x).toBe(exp);
}, done.throw, done);
}, function (x) {
done.fail('should not be called');
}, done);
});
});

Expand Down
2 changes: 2 additions & 0 deletions spec/subjects/replay-subject-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ describe('ReplaySubject', function () {
expect(results1).toEqual([3,4,5,6,7]);
expect(results2).toEqual([4,5,6,7,8]);
expect(results3).toEqual([9,10,11]);

subject.complete();
});
});

Expand Down

0 comments on commit 7f67b09

Please sign in to comment.