mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
test(route) terminal
This commit is contained in:
parent
bdf344fc2e
commit
ae6936d3c2
2 changed files with 26 additions and 7 deletions
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue