Skip to content

Commit

Permalink
test(): add test for error logging
Browse files Browse the repository at this point in the history
Add test to ensure that errors are being logged appropriately.
  • Loading branch information
TylorS committed Dec 8, 2015
1 parent b6b13bb commit 2b0d3d7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global describe, it */
import assert from 'assert';
import sinon from 'sinon';
import { run } from '../src';
import Most from 'most';

Expand Down Expand Up @@ -81,5 +82,30 @@ describe(`Cycle`, () => {
done();
});
});

it(`should report errors from main() to the console`, done => {
const sandbox = sinon.sandbox.create();
sandbox.stub(console, `error`);

const main = sources => ({
other: sources.other.take(1).startWith('a').map(() => {
throw new Error('malfunction')
})
});

const driver = () => Most.just(`b`);

run(main, {other: driver});

setTimeout(() => {
sinon.assert.calledOnce(console.error);
sinon.assert.calledWithExactly(
console.error,
sinon.match("malfunction")
);
sandbox.restore();
done();
}, 10);
});
});
});

0 comments on commit 2b0d3d7

Please sign in to comment.