Skip to content

Commit

Permalink
test: add missing test cases for ensure and is-ignored (#987)
Browse files Browse the repository at this point in the history
* test(esnure): add tests for untested code paths

* test(is-ignored): add test case for untested code path
  • Loading branch information
armano2 committed Feb 9, 2020
1 parent ec4af58 commit d5c601f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions @commitlint/ensure/src/enum.test.ts
Expand Up @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion @commitlint/is-ignored/src/is-ignored.test.ts
Expand Up @@ -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', () => {
Expand All @@ -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:');
});

0 comments on commit d5c601f

Please sign in to comment.