feature(exit) add ability to receive error as argument

This commit is contained in:
coderaiser 2018-10-12 12:11:15 +03:00
parent 2b9fca8485
commit aacf36babd
3 changed files with 23 additions and 6 deletions

View file

@ -32,3 +32,19 @@ test('cloudcmd: exit: console.error', (t) => {
t.end();
});
test('cloudcmd: exit.error: console.error: error', (t) => {
const {exit:exitOriginal} = process;
const {error} = console;
console.error = sinon.stub();
process.exit = sinon.stub();
exit(Error('hello world'));
t.ok(console.error.calledWith('hello world'), 'should call console.error');
process.exit = exitOriginal;
console.error = error;
t.end();
});