Skip to content

Commit

Permalink
test(Observable.prototype.subscribe): test passing anonymous observers
Browse files Browse the repository at this point in the history
add tests to be sure all permutations of objects that could be observers can be passed without error

related Reactive-Extensions#723
  • Loading branch information
benlesh committed Nov 13, 2015
1 parent b2e87d1 commit 490619b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spec/observable-spec.js
Expand Up @@ -108,6 +108,38 @@ describe('Observable', function () {
sub.unsubscribe();
expect(unsubscribeCalled).toBe(true);
});

describe('when called with an anonymous observer', function () {
it('should accept an anonymous observer with just a next function', function () {
Observable.of(1).subscribe({
next: function next(x) {
expect(x).toBe(1);
}
});
});

it('should accept an anonymous observer with just an error function', function () {
Observable.throw('bad').subscribe({
error: function error(err) {
expect(err).toBe('bad');
}
});
});

it('should accept an anonymous observer with just a complete function', function (done) {
Observable.empty().subscribe({
complete: function complete() {
done();
}
});
});

it('should accept an anonymous observer with no functions at all', function () {
expect(function testEmptyObject() {
Observable.empty().subscribe({});
}).not.toThrow();
});
});
});
});

Expand Down

0 comments on commit 490619b

Please sign in to comment.