Skip to content

Commit

Permalink
restructure tests for Sink.fail
Browse files Browse the repository at this point in the history
  • Loading branch information
srijs committed May 22, 2016
1 parent c90d903 commit e0984d6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/sink-spec.ts
Expand Up @@ -33,20 +33,22 @@ describe('Stream', () => {

describe('fails', () => {

it('fails with an empty input', () => {
it('fails when calling onStart', () => {
const reason = new Error('some error');
const sink = Sink.fail(reason);
const source = Source.empty();
const promise = source.pipe(sink);
return chai.expect(promise).to.eventually.be.rejectedWith(reason);
return chai.expect(sink.onStart()).to.eventually.be.rejectedWith(reason);
});

it('fails with a non-empty input', () => {
it('fails when calling onData', () => {
const reason = new Error('some error');
const sink = Sink.fail(reason);
const source = Source.fromArray([1, 2, 3]);
const promise = source.pipe(sink);
return chai.expect(promise).to.eventually.be.rejectedWith(reason);
return chai.expect(sink.onData({}, {})).to.eventually.be.rejectedWith(reason);
});

it('fails when calling onEnd', () => {
const reason = new Error('some error');
const sink = Sink.fail(reason);
return chai.expect(sink.onEnd({})).to.eventually.be.rejectedWith(reason);
});

});
Expand Down

0 comments on commit e0984d6

Please sign in to comment.