1
0
Fork 0

cover config types better

This commit is contained in:
ssube 2019-11-15 19:01:28 -06:00 committed by Sean Sube
parent 6c33b81610
commit fb60b09db8
2 changed files with 16 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import { NotFoundError } from '../../../src/error/NotFoundError';
import { describeLeaks, itLeaks } from '../../helpers/async';
const TEST_ROOT = '../test/config/type';
const CONFIG_MISSING = 'missing.yml';
describeLeaks('include config type', async () => {
itLeaks('should resolve existing files', async () => {
@ -15,7 +16,7 @@ describeLeaks('include config type', async () => {
itLeaks('should throw when resolving missing files', async () => {
expect(() => {
includeType.resolve(join(TEST_ROOT, 'missing.yml'));
includeType.resolve(join(TEST_ROOT, CONFIG_MISSING));
}).to.throw(NotFoundError);
});
@ -25,7 +26,13 @@ describeLeaks('include config type', async () => {
itLeaks('should throw when constructing missing files', async () => {
expect(() => {
includeType.construct(join(TEST_ROOT, 'missing.yml'));
includeType.construct(join(TEST_ROOT, CONFIG_MISSING));
}).to.throw(BaseError);
});
itLeaks('should throw when resolving missing files', async () => {
expect(() => {
includeType.resolve(join(TEST_ROOT, CONFIG_MISSING));
}).to.throw(BaseError);
});
});

View File

@ -1,6 +1,7 @@
import { expect } from 'chai';
import { regexpType } from '../../../src/config/type/Regexp';
import { InvalidArgumentError } from '../../../src/error/InvalidArgumentError';
import { describeLeaks, itLeaks } from '../../helpers/async';
describeLeaks('regexp config type', async () => {
@ -21,7 +22,11 @@ describeLeaks('regexp config type', async () => {
expect(regexpType.resolve('/foo/notrealflags')).to.equal(false);
});
itLeaks('should not match regex embedded in a longer string', async () => {
expect(regexpType.resolve('some/regex/with-padding')).to.equal(false);
itLeaks('should not match regexp embedded in a longer string', async () => {
expect(regexpType.resolve('some/regexp/with-padding')).to.equal(false);
});
itLeaks('should throw when constructing an invalid regexp', async () => {
expect(() => regexpType.construct('/foo/notrealflags')).to.throw(InvalidArgumentError);
});
});