2019-11-10 03:56:49 +00:00
|
|
|
import { expect } from 'chai';
|
2019-11-14 05:07:54 +00:00
|
|
|
import mockFs from 'mock-fs';
|
2019-11-10 03:56:49 +00:00
|
|
|
|
|
|
|
import { main, STATUS_SUCCESS } from '../src/app';
|
2019-11-14 05:07:54 +00:00
|
|
|
import { describeLeaks, itLeaks } from './helpers/async';
|
2019-11-10 03:56:49 +00:00
|
|
|
|
|
|
|
describeLeaks('main app', async () => {
|
2019-11-14 05:07:54 +00:00
|
|
|
itLeaks('completion should succeed', async () => {
|
2019-11-10 03:56:49 +00:00
|
|
|
const status = await main(['node', 'test', 'complete']);
|
|
|
|
expect(status).to.equal(STATUS_SUCCESS);
|
|
|
|
});
|
2019-11-14 05:07:54 +00:00
|
|
|
|
|
|
|
itLeaks('should list rules and exit', async () => {
|
2019-11-14 05:27:16 +00:00
|
|
|
mockFs({
|
|
|
|
docs: {
|
|
|
|
'config.yml': 'data: {logger: {level: debug, name: test, stream: !stream stderr}}',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const status = await main([
|
|
|
|
'node', 'test', 'list',
|
|
|
|
'--config-path', 'docs',
|
|
|
|
'--config-name', 'config.yml',
|
|
|
|
]);
|
|
|
|
|
|
|
|
mockFs.restore();
|
|
|
|
|
2019-11-14 05:07:54 +00:00
|
|
|
expect(status).to.equal(STATUS_SUCCESS);
|
|
|
|
});
|
|
|
|
|
|
|
|
itLeaks('should load the source', async () => {
|
|
|
|
mockFs({
|
|
|
|
'docs': {
|
|
|
|
'config.yml': 'data: {logger: {level: debug, name: test, stream: !stream stderr}}',
|
|
|
|
},
|
|
|
|
'test.yml': 'hello world',
|
|
|
|
});
|
|
|
|
|
|
|
|
const status = await main([
|
|
|
|
'node', 'test',
|
|
|
|
'--config-path', 'docs',
|
|
|
|
'--config-name', 'config.yml',
|
|
|
|
'--source', 'test.yml',
|
|
|
|
]);
|
|
|
|
|
|
|
|
mockFs.restore();
|
|
|
|
|
|
|
|
expect(status).to.equal(STATUS_SUCCESS);
|
|
|
|
});
|
2019-11-10 03:56:49 +00:00
|
|
|
});
|