Skip to content

Commit b55693c

Browse files
committed
test(core): add superficial tests for lint()
1 parent 741b633 commit b55693c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

@commitlint/core/src/lint.test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import test from 'ava';
2+
import lint from './lint';
3+
4+
test('throws without params', t => {
5+
t.throws(() => lint());
6+
});
7+
8+
test('throws with empty message', t => {
9+
t.throws(() => lint(''));
10+
});
11+
12+
test('positive on stub message and no rule', t => {
13+
const actual = lint('foo: bar');
14+
t.true(actual.valid);
15+
});
16+
17+
test('positive on stub message and adhered rule', t => {
18+
const actual = lint('foo: bar', {
19+
'type-enum': [2, 'always', ['foo']]
20+
});
21+
t.true(actual.valid);
22+
});
23+
24+
test('negative on stub message and broken rule', t => {
25+
const actual = lint('foo: bar', {
26+
'type-enum': [2, 'never', ['foo']]
27+
});
28+
t.false(actual.valid);
29+
});
30+
31+
test('positive on ignored message and broken rule', t => {
32+
const actual = lint('Revert "some bogus commit"', {
33+
'type-empty': [2, 'never']
34+
});
35+
t.true(actual.valid);
36+
});

0 commit comments

Comments
 (0)