mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-17 16:38:18 +00:00
37 lines
1 KiB
JavaScript
37 lines
1 KiB
JavaScript
import {test} from 'supertape';
|
|
import {tryCatch} from 'try-catch';
|
|
import {showConfig} from './show-config.js';
|
|
|
|
test('cloudcmd: show-config: no arguments', (t) => {
|
|
const [error] = tryCatch(showConfig);
|
|
|
|
t.equal(error.message, 'config could not be empty!', 'should throw when no config');
|
|
t.end();
|
|
});
|
|
|
|
test('cloudcmd: show-config: bad arguments', (t) => {
|
|
const [error] = tryCatch(showConfig, 'hello');
|
|
|
|
t.equal(error.message, 'config should be an object!', 'should throw when config not object');
|
|
t.end();
|
|
});
|
|
|
|
test('cloudcmd: show-config: empty: return', (t) => {
|
|
t.equal(showConfig({}), '', 'should return string');
|
|
t.end();
|
|
});
|
|
|
|
test('cloudcmd: show-config: return', (t) => {
|
|
const config = {
|
|
hello: 'world',
|
|
};
|
|
|
|
const result = [
|
|
'+-------+--------------------------------+\n',
|
|
'| hello | world |\n',
|
|
'+-------+--------------------------------+\n',
|
|
].join('');
|
|
|
|
t.equal(showConfig(config), result, 'should return table');
|
|
t.end();
|
|
});
|