mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
34 lines
810 B
JavaScript
34 lines
810 B
JavaScript
'use strict';
|
|
|
|
const test = require('tape');
|
|
const exit = require('./exit');
|
|
const diff = require('sinon-called-with-diff');
|
|
const sinon = diff(require('sinon'));
|
|
|
|
test('cloudcmd: exit: process.exit', (t) => {
|
|
const {exit:exitOriginal} = process;
|
|
process.exit = sinon.stub();
|
|
|
|
exit();
|
|
t.ok(process.exit.calledWith(1), 'should call process.exit');
|
|
process.exit = exitOriginal;
|
|
|
|
t.end();
|
|
});
|
|
|
|
test('cloudcmd: exit: console.error', (t) => {
|
|
const {exit:exitOriginal} = process;
|
|
const {error} = console;
|
|
|
|
console.error = sinon.stub();
|
|
process.exit = sinon.stub();
|
|
|
|
exit('hello world');
|
|
t.ok(console.error.calledWith('hello world'), 'should call console.error');
|
|
|
|
process.exit = exitOriginal;
|
|
console.error = error;
|
|
|
|
t.end();
|
|
});
|
|
|