/
executeConsoleCommand.test.ts
33 lines (29 loc) 路 1.16 KB
/
executeConsoleCommand.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
import g from './_globals';
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import { executeConsoleCommand } from '../lib/index';
import { fail } from 'assert';
require('dotenv').config();
chai.use(chaiAsPromised);
describe('/api/executeconsolecommand', async () => {
it('Returns command, parameters and result', async () => {
const response = await executeConsoleCommand(g.getTestServer(), "help");
chai.expect(response.command).to.be.a('string');
chai.expect(response.parameters).to.be.a('string');
});
it('Executes a command correctly', async () => {
const response = await executeConsoleCommand(g.getTestServer(), "help");
chai.expect(response.command).to.eq('help');
chai.expect(response.parameters).to.eq('');
chai.expect(response.result).to.include("*** Generic Console Help ***");
});
it('Executes a an unknown command - foobar', async () => {
try {
await executeConsoleCommand(g.getTestServer(), "foobar");
fail('should have failed');
} catch (e) {
chai.expect(e).to.be.a('error');
}
});
});