Skip to content

Commit d5c601f

Browse files
authored
test: add missing test cases for ensure and is-ignored (#987)
* test(esnure): add tests for untested code paths * test(is-ignored): add test case for untested code path
1 parent ec4af58 commit d5c601f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

@commitlint/ensure/src/enum.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ test('false for no params', () => {
55
expect(actual).toBe(false);
66
});
77

8+
test('false for not array enums', () => {
9+
const actual = ensure('a', 'a' as any);
10+
expect(actual).toBe(false);
11+
});
12+
813
test('true for a against a', () => {
914
const actual = ensure('a', ['a']);
1015
expect(actual).toBe(true);

@commitlint/is-ignored/src/is-ignored.test.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ test('should throw error if ignores is not an array', () => {
150150
isIgnored(ignoredString, {
151151
ignores: 'throws error'
152152
} as any);
153-
}).toThrow();
153+
}).toThrow('ignores must be of type array, received ');
154154
});
155155

156156
test('should return true for custom ignores as function', () => {
@@ -161,3 +161,12 @@ test('should return true for custom ignores as function', () => {
161161
})
162162
).toBe(true);
163163
});
164+
165+
test('should throw error if any element of ignores is not a function', () => {
166+
const ignoredString = 'this should be ignored';
167+
expect(() => {
168+
isIgnored(ignoredString, {
169+
ignores: ['throws error']
170+
} as any);
171+
}).toThrow('ignores must be array of type function, received items of type:');
172+
});

0 commit comments

Comments
 (0)