Skip to content

Commit

Permalink
test(Subscriber): add test for no error propagation
Browse files Browse the repository at this point in the history
Add test to assert that error happening in the next() handler should not propagate to the error()
handler.

For issue #1135.
  • Loading branch information
staltz committed Jan 25, 2016
1 parent 7a679b6 commit 449ab58
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion spec/Subscriber-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,29 @@ describe('Subscriber', function () {
var sub = new Subscriber();
expect(sub[Rx.Symbol.rxSubscriber]()).toBe(sub);
});
});

describe('when created through create()', function () {
it('should not call error() if next() handler throws an error', function () {
var errorSpy = jasmine.createSpy('error');
var completeSpy = jasmine.createSpy('complete');

var subscriber = Subscriber.create(
function next(value) {
if (value === 2) {
throw 'error!';
}
},
errorSpy,
completeSpy
);

subscriber.next(1);
expect(function () {
subscriber.next(2);
}).toThrow('error!');

expect(errorSpy).not.toHaveBeenCalled();
expect(completeSpy).not.toHaveBeenCalled();
});
});
});

0 comments on commit 449ab58

Please sign in to comment.