-
Notifications
You must be signed in to change notification settings - Fork 934
/
Copy pathbody-max-line-length.test.ts
51 lines (42 loc) · 1.46 KB
/
body-max-line-length.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import parse from '@commitlint/parse';
import {bodyMaxLineLength} from './body-max-line-length';
const short = 'a';
const long = 'ab';
const value = short.length;
const messages = {
empty: 'test: subject',
short: `test: subject\n${short}`,
long: `test: subject\n${long}`,
shortMultipleLines: `test:subject\n${short}\n${short}\n${short}`,
longMultipleLines: `test:subject\n${short}\n${long}\n${short}`
};
const parsed = {
empty: parse(messages.empty),
short: parse(messages.short),
long: parse(messages.long)
};
test('with empty should succeed', async () => {
const [actual] = bodyMaxLineLength(await parsed.empty, undefined, value);
const expected = true;
expect(actual).toEqual(expected);
});
test('with short should succeed', async () => {
const [actual] = bodyMaxLineLength(await parsed.short, undefined, value);
const expected = true;
expect(actual).toEqual(expected);
});
test('with long should fail', async () => {
const [actual] = bodyMaxLineLength(await parsed.long, undefined, value);
const expected = false;
expect(actual).toEqual(expected);
});
test('with short with multiple lines should succeed', async () => {
const [actual] = bodyMaxLineLength(await parsed.short, undefined, value);
const expected = true;
expect(actual).toEqual(expected);
});
test('with long with multiple lines should fail', async () => {
const [actual] = bodyMaxLineLength(await parsed.long, undefined, value);
const expected = false;
expect(actual).toEqual(expected);
});