Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(Subscriber): add test for no error propagation #1181

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});
});