2019-10-29 03:41:52 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import { join } from 'path';
|
|
|
|
|
2019-11-17 00:10:23 +00:00
|
|
|
import { loadConfig, readConfig } from '../../src/config';
|
2019-10-29 03:41:52 +00:00
|
|
|
import { NotFoundError } from '../../src/error/NotFoundError';
|
|
|
|
import { describeLeaks, itLeaks } from '../helpers/async';
|
|
|
|
|
|
|
|
describeLeaks('load config helper', async () => {
|
|
|
|
itLeaks('should load an existing config', async () => {
|
|
|
|
const config = await loadConfig('config-stderr.yml', join(__dirname, '..', 'docs'));
|
|
|
|
expect(config.data.logger.name).to.equal('salty-dog');
|
|
|
|
});
|
|
|
|
|
2019-11-09 23:41:55 +00:00
|
|
|
itLeaks('should throw when config is missing', async () =>
|
|
|
|
expect(loadConfig('missing.yml', join(__dirname, '..', 'docs'))).to.eventually.be.rejectedWith(NotFoundError)
|
|
|
|
);
|
2019-10-29 03:41:52 +00:00
|
|
|
});
|
2019-11-17 00:10:23 +00:00
|
|
|
|
|
|
|
describeLeaks('read config helper', async () => {
|
|
|
|
itLeaks('should consume enoent errors', async () =>
|
|
|
|
expect(readConfig(join('docs', 'missing.yml'))).to.eventually.equal(undefined)
|
|
|
|
);
|
|
|
|
|
|
|
|
itLeaks('should rethrow unknown errors', async () =>
|
|
|
|
expect(readConfig('test')).to.eventually.be.rejectedWith(Error)
|
|
|
|
);
|
|
|
|
});
|