diff --git a/package.json b/package.json index 6a22072b..5dbfc669 100644 --- a/package.json +++ b/package.json @@ -173,6 +173,7 @@ "extract-text-webpack-plugin": "^4.0.0-alpha.0", "file-loader": "^1.1.4", "fresh-require": "^1.0.3", + "gritty": "^2.1.1", "gunzip-maybe": "^1.3.1", "html-looks-like": "^1.0.2", "html-webpack-exclude-assets-plugin": "^0.0.7", diff --git a/server/terminal.js b/server/terminal.js index d15d024a..b06d4d66 100644 --- a/server/terminal.js +++ b/server/terminal.js @@ -6,9 +6,7 @@ const config = require('./config'); const noop = () => {}; noop.listen = noop; -module.exports = (arg) => { - return getTerminal(config('terminal'), arg); -}; +module.exports = (arg) => getTerminal(config('terminal'), arg); function getTerminal(term, arg) { if (!term) diff --git a/test/server/route.js b/test/server/route.js index 00323e2d..fef25694 100644 --- a/test/server/route.js +++ b/test/server/route.js @@ -243,7 +243,7 @@ test('cloudcmd: route: sendIndex: encode', async (t) => { t.ok(data.includes(nameEncoded), 'should encode name'); - clear('flop'); + mockRequire.stop('flop'); clear(routePath); clear('../../server/cloudcmd'); clear(beforePath); @@ -277,7 +277,7 @@ test('cloudcmd: route: sendIndex: encode: not encoded', async (t) => { t.notOk(data.includes(name), 'should not put not encoded name'); - clear('flop'); + mockRequire.stop('flop'); clear(routePath); clear('../../server/cloudcmd'); clear(beforePath); @@ -312,7 +312,7 @@ test('cloudcmd: route: sendIndex: ddos: render', async (t) => { t.pass('should not hang up'); - clear('flop'); + mockRequire.stop('flo'); clear(routePath); clear(cloudcmdPath); clear(beforePath); @@ -335,3 +335,18 @@ test('cloudcmd: route: buttons: no terminal', async (t) => { t.end(); }); +test('cloudcmd: route: buttons: terminal', async (t) => { + const config = { + terminal: true, + terminalPath: 'gritty', + }; + + const {port, done} = await connect({config}); + const result = await getStr(`http://localhost:${port}`); + + t.notOk(/icon-terminal none/.test(result), 'should enable terminal'); + + done(); + t.end(); +}); + diff --git a/test/server/terminal.js b/test/server/terminal.js index db9d9e59..5557d1a6 100644 --- a/test/server/terminal.js +++ b/test/server/terminal.js @@ -97,6 +97,8 @@ test('cloudcmd: terminal: no arg', (t) => { t.equal(result, gritty, 'should equal'); + mock.stop('gritty'); + clean(configPath); require(configPath);