This repository has been archived by the owner on Apr 15, 2023. It is now read-only.
generated from actions/javascript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
generate-release-notes.test.js
executable file
·183 lines (154 loc) · 5.33 KB
/
generate-release-notes.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
const stripIndent = require('strip-indent');
const {generateReleaseNotes} = require('./generate-release-notes');
const dedent = string => stripIndent(string).trim();
const range = 'v3.0.0..v3.1.0';
test('generates changelog using default options', async () => {
const output = await generateReleaseNotes({range});
expect(output).toEqual(dedent(`
- f9cec2b2 Add support for \`exclude: true\` (#23)
- 8d79eb1a Meta: Add tests using jest (#22)
- 71ec95ec Meta: update self workflow (#16)
- a74ce6a1 Meta: Document how to add changelogs to old tags (#15)
- bfe14281 Bump @actions/core from 1.2.4 to 1.2.6 (#19)
- a6eb5131 Readme: make first example bare-bones (#18)
- 850de175 Meta: Update readme example to v3
[\`v3.0.0..v3.1.0\`](https://github.com/fregante/release-with-changelog/compare/v3.0.0..v3.1.0)
`));
});
test('generates changelog with custom release template', async () => {
const output = await generateReleaseNotes({
range,
releaseTemplate: dedent(`
### Changelog
{commits}
❤
`)
});
expect(output).toEqual(dedent(`
### Changelog
- f9cec2b2 Add support for \`exclude: true\` (#23)
- 8d79eb1a Meta: Add tests using jest (#22)
- 71ec95ec Meta: update self workflow (#16)
- a74ce6a1 Meta: Document how to add changelogs to old tags (#15)
- bfe14281 Bump @actions/core from 1.2.4 to 1.2.6 (#19)
- a6eb5131 Readme: make first example bare-bones (#18)
- 850de175 Meta: Update readme example to v3
❤
`));
});
test('generates changelog with custom commit template', async () => {
const output = await generateReleaseNotes({
range,
commitTemplate: '- {title}',
releaseTemplate: '{commits}'
});
expect(output).toEqual(dedent(`
- Add support for \`exclude: true\` (#23)
- Meta: Add tests using jest (#22)
- Meta: update self workflow (#16)
- Meta: Document how to add changelogs to old tags (#15)
- Bump @actions/core from 1.2.4 to 1.2.6 (#19)
- Readme: make first example bare-bones (#18)
- Meta: Update readme example to v3
`));
});
test('generates changelog with custom exclude', async () => {
const output = await generateReleaseNotes({
range,
commitTemplate: '- {title}',
releaseTemplate: '{commits}',
exclude: '^Meta|^Lint|^Refactor'
});
expect(output).toEqual(dedent(`
- Add support for \`exclude: true\` (#23)
- Bump @actions/core from 1.2.4 to 1.2.6 (#19)
- Readme: make first example bare-bones (#18)
`));
});
test('generates changelog with exclude preset', async () => {
const output = await generateReleaseNotes({
range,
commitTemplate: '- {title}',
releaseTemplate: '{commits}',
exclude: 'true'
});
expect(output).toEqual(dedent(`
- Add support for \`exclude: true\` (#23)
`));
});
test('generates changelog with date presets', async () => {
const output = await generateReleaseNotes({
range,
commitTemplate: '- {date} {title}',
releaseTemplate: '{commits}'
});
expect(output).toEqual(dedent(`
- 2020-10-21 Add support for \`exclude: true\` (#23)
- 2020-10-20 Meta: Add tests using jest (#22)
- 2020-10-02 Meta: update self workflow (#16)
- 2020-10-02 Meta: Document how to add changelogs to old tags (#15)
- 2020-10-02 Bump @actions/core from 1.2.4 to 1.2.6 (#19)
- 2020-09-22 Readme: make first example bare-bones (#18)
- 2020-09-18 Meta: Update readme example to v3
`));
});
test('generates changelog with custom date presets', async () => {
const output = await generateReleaseNotes({
range,
commitTemplate: '- {date} {title}',
releaseTemplate: '{commits}',
dateFormat: '%d.%m.%Y'
});
expect(output).toEqual(dedent(`
- 21.10.2020 Add support for \`exclude: true\` (#23)
- 20.10.2020 Meta: Add tests using jest (#22)
- 02.10.2020 Meta: update self workflow (#16)
- 02.10.2020 Meta: Document how to add changelogs to old tags (#15)
- 02.10.2020 Bump @actions/core from 1.2.4 to 1.2.6 (#19)
- 22.09.2020 Readme: make first example bare-bones (#18)
- 18.09.2020 Meta: Update readme example to v3
`));
});
test('ensure that replacements aren’t applied in commit titles', async () => {
const output = await generateReleaseNotes({
range: 'v3.1.0..v3.2.0'
});
expect(output).toEqual(expect.stringContaining('{date}'));
});
test('generates changelog using reverse optios', async () => {
const output = await generateReleaseNotes({
range,
sort: 'asc'
});
expect(output).toEqual(dedent(`
- 850de175 Meta: Update readme example to v3
- a6eb5131 Readme: make first example bare-bones (#18)
- bfe14281 Bump @actions/core from 1.2.4 to 1.2.6 (#19)
- a74ce6a1 Meta: Document how to add changelogs to old tags (#15)
- 71ec95ec Meta: update self workflow (#16)
- 8d79eb1a Meta: Add tests using jest (#22)
- f9cec2b2 Add support for \`exclude: true\` (#23)
[\`v3.0.0..v3.1.0\`](https://github.com/fregante/release-with-changelog/compare/v3.0.0..v3.1.0)
`));
});
test('generates changelog with all commits excluded', async () => {
const output = await generateReleaseNotes({
range,
commitTemplate: '- {title}',
releaseTemplate: '{commits}',
exclude: 'a|e|i|o|u'
});
expect(output).toEqual(dedent(`
_Maintenance release_
`));
});
test('generates changelog with all commits excluded and skip-on-empty', async () => {
const output = await generateReleaseNotes({
range,
commitTemplate: '- {title}',
releaseTemplate: '{commits}',
exclude: 'a|e|i|o|u',
skipOnEmpty: true
});
expect(output).toEqual(undefined);
});