mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
fix(terminal) config: terminal and terminalPath checked before set
This commit is contained in:
parent
a260a921ba
commit
10307291a3
3 changed files with 21 additions and 10 deletions
|
|
@ -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';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue