-
Notifications
You must be signed in to change notification settings - Fork 0
/
pr_summary.test.js
123 lines (112 loc) · 3.19 KB
/
pr_summary.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
'use strict';
const {
oddCommits,
simpleCommits,
firstTimerPR,
semverMajorPR,
emptyProfilePR
} = require('../fixtures/data');
const TestCLI = require('../fixtures/test_cli');
const PRSummary = require('../../lib/pr_summary');
describe('PRSummary', () => {
const argv = { prid: 16348, owner: 'nodejs', repo: 'node' };
it('#display() first timer with odd commits', () => {
const cli = new TestCLI();
const prData = {
pr: firstTimerPR,
commits: oddCommits,
authorIsNew() {
return true;
}
};
const summary = new PRSummary(argv, cli, prData);
const expectedLogs = {
log: [
// commits
[' - doc: some changes'],
[' - doc: some changes 2'],
[' - test: some changes'],
[' - test: some changes 2'],
[' - [squash] fix typo'],
[' - fixup! fix something'],
// committers
[' - Their Github Account email <pr_author@example.com>'],
[' - GitHub <noreply@github.com>'],
[' - Baz User <baz@example.com>']
],
table: [
['Title', 'test: awesome changes (#16348)'],
['Author',
'Their Github Account email <pr_author@example.com>' +
' (@pr_author, first-time contributor)'],
['Branch', 'pr_author:awesome-changes -> nodejs:master'],
['Labels', 'needs-ci, test, doc'],
['Commits', '6'],
['Committers', '3']
]
};
summary.display();
cli.assertCalledWith(expectedLogs);
});
it('#display() old timer with simple commits', () => {
const cli = new TestCLI();
const prData = {
pr: semverMajorPR,
commits: simpleCommits,
authorIsNew() {
return false;
}
};
const summary = new PRSummary(argv, cli, prData);
const expectedLogs = {
log: [
// commits
[' - doc: some changes'],
// committers
[' - Their Github Account email <pr_author@example.com>']
],
table: [
['Title', 'lib: awesome changes (#16348)'],
['Author',
'Their Github Account email <pr_author@example.com>' +
' (@pr_author)'],
['Branch', 'pr_author:awesome-changes -> nodejs:master'],
['Labels', 'semver-major'],
['Commits', '1'],
['Committers', '1']
]
};
summary.display();
cli.assertCalledWith(expectedLogs);
});
it('displays warning if pr author/email is not present', () => {
const cli = new TestCLI();
const prData = {
pr: emptyProfilePR,
commits: simpleCommits,
authorIsNew() {
return false;
}
};
const expectedLogs = {
log: [
[' - doc: some changes'],
[' - Their Github Account email <pr_author@example.com>']
],
table: [
['Title', 'doc: fix mdn links (#16348)'],
['Branch', 'pr_author:fix-links -> nodejs:master'],
['Labels', 'doc'],
['Commits', '1'],
['Committers', '1']
],
warn: [
['Could not retrieve the email or name ' +
"of the PR author's from user's GitHub profile!"]
]
};
const summary = new PRSummary(argv, cli, prData);
summary.display();
cli.assertCalledWith(expectedLogs);
});
});