mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
test(exit) add
This commit is contained in:
parent
ac1c8efd8e
commit
084bc60d5e
2 changed files with 33 additions and 0 deletions
|
|
@ -176,6 +176,7 @@
|
|||
"request": "^2.76.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"shortdate": "^1.0.1",
|
||||
"sinon": "^2.1.0",
|
||||
"socket.io-client": "^1.5.1",
|
||||
"stylelint": "^7.0.2",
|
||||
"stylelint-config-standard": "^16.0.0",
|
||||
|
|
|
|||
32
test/server/exit.js
Normal file
32
test/server/exit.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('tape');
|
||||
const exit = require('../../server/exit');
|
||||
const sinon = 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();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue