From fb60b09db861383039c892b49cce55107087ebab Mon Sep 17 00:00:00 2001 From: ssube Date: Fri, 15 Nov 2019 19:01:28 -0600 Subject: [PATCH] cover config types better --- test/config/type/TestInclude.ts | 11 +++++++++-- test/config/type/TestRegexp.ts | 9 +++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/test/config/type/TestInclude.ts b/test/config/type/TestInclude.ts index 3025098..e3603d7 100644 --- a/test/config/type/TestInclude.ts +++ b/test/config/type/TestInclude.ts @@ -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); }); }); diff --git a/test/config/type/TestRegexp.ts b/test/config/type/TestRegexp.ts index d7c998c..7507ba6 100644 --- a/test/config/type/TestRegexp.ts +++ b/test/config/type/TestRegexp.ts @@ -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); }); });