forked from ellistarn/conventional-commits
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.test.ts
66 lines (53 loc) · 1.84 KB
/
index.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
import * as core from '@actions/core'
import {validateCommits} from "./index"
jest.mock('@actions/core');
test("should handle conventional commits",() => {
const commits = [
{ message: 'fix: foo' },
{ message: 'chore: foo' },
]
validateCommits(commits)
})
test("should ignore (not throw) merge commits",() => {
const commits = [
{ message: 'Merge foo into bar' },
{ message: 'Backmerge of foo into barar' }
]
validateCommits(commits)
})
test("should handle merge commits with quotes",() => {
const commits = [
{ message: `Backmerge of 'foo/internal-dash-dash' into barar` }
]
validateCommits(commits)
})
test("should handle merge commits with many lines",() => {
const commits = [
{ message: `Backmerge of 'foo/internal-dash-dash' into barar
Some details foo
# CONFLICTS
# Foo
# bar
` }
]
validateCommits(commits)
})
test("should only pass on first line to core.info when ignoring", () => {
validateCommits([{message: 'Merge something\nfoo\nbar'}])
expect(core.info).toHaveBeenCalledWith("🤫 Ignoring 'Merge something'")
})
test("should not ignore messages that has 'merge' somewhere in their body", () => {
validateCommits([{message: 'fix: something\nfoo\nbar merge merge MERGE'}])
expect(core.info).toHaveBeenCalledWith("✅ fix: something")
})
test("should only output the first line of a commit message", () => {
validateCommits([{message: 'fix: something\nfoo\nbar'}])
expect(core.info).toHaveBeenCalledWith("✅ fix: something")
})
test("should report error on unconventional messages",() => {
const commits = [
{ message: 'Repair and update database by default in development' }
]
validateCommits(commits)
expect(core.error).toHaveBeenCalledWith("❌ Repair and update database by default in development")
})