1
0
Fork 0
cautious-journey/test/config/TestConfig.ts

35 lines
853 B
TypeScript
Raw Normal View History

import { expect } from 'chai';
import { vol } from 'memfs';
import { Filesystem, initConfig, setFs } from '../../src/config';
describe('config', () => {
2020-08-31 01:11:11 +00:00
describe('init config', () => {
it('should load a valid config', async () => {
const path = 'valid.yml';
vol.fromJSON({
[path]: `
logger:
level: info
name: test
projects: []`,
});
const restore = setFs(vol.promises as Filesystem);
const config = await initConfig(path);
restore();
expect(config.logger.name).to.equal('test');
});
it('should throw on invalid config', async () => {
await expect(initConfig('./invalid.yml')).to.eventually.be.rejectedWith(Error);
});
it('should throw on missing paths', async () => {
await expect(initConfig('.fake')).to.eventually.be.rejectedWith(Error);
});
});
});