-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.js
83 lines (80 loc) · 1.67 KB
/
tests.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const assert = require('assert/strict');
const issuecheck = require('./issuecheck.js');
const tests = {
testNoneContains: () => {
assert.throws(() => {
issuecheck.findIssue("ENG-", "title", "description", "branch");
},
RegExp("Issue not found")
);
},
testTitle: () => {
const issue = issuecheck.findIssue(
"ENG-",
"feat: ENG-1234 Something of value",
"description",
"branch"
);
assert.equal(issue, "ENG-1234");
},
testTitleAtEnd: () => {
const issue = issuecheck.findIssue(
"ENG-",
"feat: ENG-1234",
"description",
"branch"
);
assert.equal(issue, "ENG-1234");
},
testDescription: () => {
const issue = issuecheck.findIssue(
"ENG-",
"title",
`some
multi
line
Fixes ENG-1234
something else`,
"branch"
);
assert.equal(issue, "ENG-1234");
},
testDescriptionOnly: () => {
const issue = issuecheck.findIssue(
"ENG-",
"title",
"ENG-1234",
"branch"
);
assert.equal(issue, "ENG-1234");
},
testBranch: () => {
const issue = issuecheck.findIssue(
"ENG-",
"title",
"description",
"user/eng-1234"
);
assert.equal(issue, "ENG-1234");
},
testBranchWithTitle: () => {
const issue = issuecheck.findIssue(
"ENG-",
"title",
"description",
"user/eng-1234-doing-something-cool"
);
assert.equal(issue, "ENG-1234");
},
};
function run() {
for (const [key, test] of Object.entries(tests)) {
try {
test()
console.log(`${key} passed`)
} catch(error) {
console.log(`${key} failed: ${error}`)
}
}
};
run();