fix(terminal) config: terminal and terminalPath checked before set

This commit is contained in:
coderaiser 2017-04-25 11:56:49 +03:00
parent a260a921ba
commit 10307291a3
3 changed files with 21 additions and 10 deletions

View file

@ -7,16 +7,19 @@ const sinon = diff(require('sinon'));
const configPath = '../../server/config';
const terminalPath = '../../server/terminal';
test('cloudcmd: terminal: disabled', (t) => {
clean(terminalPath);
stub(configPath, () => {
return false;
});
const terminal = require(terminalPath);
const fn = terminal();
const terminal = require('../../server/terminal');
t.notOk(fn, 'should return noop');
const fn = terminal();
const noop = () => {};
t.equal(String(fn), String(noop), 'should return noop');
clean(configPath);
require(configPath);
@ -28,8 +31,9 @@ test('cloudcmd: terminal: disabled: listen', (t) => {
clean(terminalPath);
stub(configPath, () => false);
const terminal = require('../../server/terminal');
const fn = terminal.listen();
const terminal = require(terminalPath);
const fn = terminal().listen();
t.notOk(fn, 'should return noop');
@ -45,7 +49,9 @@ test('cloudcmd: terminal: enabled', (t) => {
clean(terminalPath);
stub(configPath, () => true);
require(terminalPath);
const terminal = require(terminalPath);
terminal();
const msg = 'cloudcmd --terminal: path must be a string';