forked from conventional-changelog/commitlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubject-full-stop.test.ts
82 lines (71 loc) · 2.52 KB
/
subject-full-stop.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import parse from '@commitlint/parse';
import {subjectFullStop} from './subject-full-stop';
const messages = {
empty: 'test:\n',
with: `test: subject.\n`,
without: `test: subject\n`,
standardScopeWith: `type(scope): subject.\n`,
nonStandardScopeWith: 'type.scope: subject.\n',
ellipsisMessage: 'test: subject ends with ellipsis...',
};
const parsed = {
empty: parse(messages.empty),
with: parse(messages.with),
without: parse(messages.without),
standardScopeWith: parse(messages.standardScopeWith),
nonStandardScopeWith: parse(messages.nonStandardScopeWith),
ellipsisMessage: parse(messages.ellipsisMessage),
};
test('empty against "always" should succeed', async () => {
const [actual] = subjectFullStop(await parsed.empty, 'always', '.');
const expected = true;
expect(actual).toEqual(expected);
});
test('empty against "never ." should succeed', async () => {
const [actual] = subjectFullStop(await parsed.empty, 'never', '.');
const expected = true;
expect(actual).toEqual(expected);
});
test('with against "always ." should succeed', async () => {
const [actual] = subjectFullStop(await parsed.with, 'always', '.');
const expected = true;
expect(actual).toEqual(expected);
});
test('with against "never ." should fail', async () => {
const [actual] = subjectFullStop(await parsed.with, 'never', '.');
const expected = false;
expect(actual).toEqual(expected);
});
test('without against "always ." should fail', async () => {
const [actual] = subjectFullStop(await parsed.without, 'always', '.');
const expected = false;
expect(actual).toEqual(expected);
});
test('without against "never ." should succeed', async () => {
const [actual] = subjectFullStop(await parsed.without, 'never', '.');
const expected = true;
expect(actual).toEqual(expected);
});
test('commit message title with standard scope and full-stop against "never ." should fail', async () => {
const [actual] = subjectFullStop(
await parsed.standardScopeWith,
'never',
'.'
);
const expected = false;
expect(actual).toEqual(expected);
});
test('commit message title with non standard scope and full-stop against "never ." should fail', async () => {
const [actual] = subjectFullStop(
await parsed.nonStandardScopeWith,
'never',
'.'
);
const expected = false;
expect(actual).toEqual(expected);
});
test('ellipsis is not fullstop so commit title ending with it against "never ." should not fail', async () => {
const [actual] = subjectFullStop(await parsed.ellipsisMessage, 'never', '.');
const expected = true;
expect(actual).toEqual(expected);
});