-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
59 lines (57 loc) · 1.63 KB
/
index.test.js
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
const {
findIssueKeysFromBranchName,
addIssueKeysToMessage,
} = require("./utils");
test("can find issue keys in a branch name", () => {
const MESSAGE = "hello there";
const testCases = [
{
branchName: "TASK-100",
expectedIssueKeys: ["TASK-100"],
result: "TASK-100: hello there",
},
{
branchName: "JIRA-1-is-the-best",
expectedIssueKeys: ["JIRA-1"],
result: "JIRA-1: hello there",
},
{
branchName: "ROBOT-777-LETS-get-it-done-2",
expectedIssueKeys: ["ROBOT-777"],
result: "ROBOT-777: hello there",
},
{
// with an issue directory
branchName: "issue/EASY-42-its-too-easy-baby",
expectedIssueKeys: ["EASY-42"],
result: "EASY-42: hello there",
},
{
// issue key as a directory
branchName: "TST-123/test-branch-name",
expectedIssueKeys: ["TST-123"],
result: "TST-123: hello there",
},
{
// two issue keys in a branch is a bit crazy, but it works!
branchName: "TST-123-TST-456/test-branch-name",
expectedIssueKeys: ["TST-123", "TST-456"],
result: "TST-123 TST-456: hello there",
},
{
branchName: "test-500-lowercase-wont-work",
expectedIssueKeys: null,
result: "hello there",
},
{
branchName: "TEST100-nope-not-like-this",
expectedIssueKeys: null,
result: "hello there",
},
];
testCases.forEach((testCase) => {
const issueKeys = findIssueKeysFromBranchName(testCase.branchName);
expect(issueKeys).toEqual(testCase.expectedIssueKeys);
expect(addIssueKeysToMessage(issueKeys, MESSAGE)).toEqual(testCase.result);
});
});