test(route) terminal

This commit is contained in:
coderaiser 2018-11-14 16:49:13 +02:00
parent bdf344fc2e
commit ae6936d3c2
2 changed files with 26 additions and 7 deletions

View file

@ -14,6 +14,7 @@ const fixtureDir = path.join(__dirname, '..', 'test', 'fixture');
const routePath = './route';
const cloudcmdPath = './cloudcmd';
const terminalPath = './terminal';
const cloudcmd = require(cloudcmdPath);
const serveOnce = require('serve-once');
@ -362,7 +363,6 @@ test('cloudcmd: route: buttons: no terminal', async (t) => {
config,
}
const {request} = serveOnce(cloudcmd);
const {body} = await request.get('/', {
options
});
@ -389,22 +389,39 @@ test('cloudcmd: route: no termianl: /fs', async (t) => {
t.end();
});
test('cloudcmd: route: buttons: terminal', async (t) => {
test('cloudcmd: route: buttons: terminal: can not load', async (t) => {
const config = {
terminal: true,
terminalPath: 'gritty',
terminalPath: 'xxxxxxxxxxxx',
};
const options = {
config,
}
};
const {request} = serveOnce(cloudcmd);
const {body} = await request.get('/', {
options
});
t.notOk(/icon-terminal none/.test(body), 'should enable terminal');
t.ok(/icon-terminal none/.test(body), 'should not enable terminal');
t.end();
});
test('cloudcmd: route: buttons: terminal', async (t) => {
const config = {
terminal: true,
terminalPath: 'console-io',
};
const options = {
config,
};
const {body} = await request.get('/', {
options
});
t.notOk(/icon-terminal none/.test(body), 'should not enable terminal');
t.end();
});

View file

@ -3,7 +3,9 @@
const tryCatch = require('try-catch');
const config = require('./config');
const noop = () => {};
const noop = (req, res, next) => {
next && next();
};
noop.listen = noop;
module.exports = (arg) => getTerminal(config('terminal'), arg);