From 28b27586ba17dc7ea581bc1fd06e9079bd4f6bc2 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 9 Feb 2020 22:49:37 +0100 Subject: [PATCH 1/2] test(esnure): add tests for untested code paths --- @commitlint/ensure/src/enum.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/@commitlint/ensure/src/enum.test.ts b/@commitlint/ensure/src/enum.test.ts index 599234021a..ab7d5d0ff7 100644 --- a/@commitlint/ensure/src/enum.test.ts +++ b/@commitlint/ensure/src/enum.test.ts @@ -5,6 +5,11 @@ test('false for no params', () => { expect(actual).toBe(false); }); +test('false for not array enums', () => { + const actual = ensure('a', 'a' as any); + expect(actual).toBe(false); +}); + test('true for a against a', () => { const actual = ensure('a', ['a']); expect(actual).toBe(true); From c487eb477df9560cada4f420aeff343477447bd8 Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 9 Feb 2020 22:50:25 +0100 Subject: [PATCH 2/2] test(is-ignored): add test case for untested code path --- @commitlint/is-ignored/src/is-ignored.test.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/@commitlint/is-ignored/src/is-ignored.test.ts b/@commitlint/is-ignored/src/is-ignored.test.ts index 663080223b..e50524dc9c 100644 --- a/@commitlint/is-ignored/src/is-ignored.test.ts +++ b/@commitlint/is-ignored/src/is-ignored.test.ts @@ -150,7 +150,7 @@ test('should throw error if ignores is not an array', () => { isIgnored(ignoredString, { ignores: 'throws error' } as any); - }).toThrow(); + }).toThrow('ignores must be of type array, received '); }); test('should return true for custom ignores as function', () => { @@ -161,3 +161,12 @@ test('should return true for custom ignores as function', () => { }) ).toBe(true); }); + +test('should throw error if any element of ignores is not a function', () => { + const ignoredString = 'this should be ignored'; + expect(() => { + isIgnored(ignoredString, { + ignores: ['throws error'] + } as any); + }).toThrow('ignores must be array of type function, received items of type:'); +});