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 13, 2016
1 parent 7a679b6 commit e7c5ecf
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion spec/Subscriber-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,34 @@ 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 (done) {
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);
try {
subscriber.next(2);
} catch (err) {
expect(err).toEqual('error!');
}

setTimeout(function () {
expect(errorSpy).not.toHaveBeenCalled();
expect(completeSpy).not.toHaveBeenCalled();
done();
});
});
});
});

0 comments on commit e7c5ecf

Please sign in to comment.