generated from actions/typescript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathtransform.test.ts
More file actions
683 lines (646 loc) · 20.2 KB
/
transform.test.ts
File metadata and controls
683 lines (646 loc) · 20.2 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
import {buildChangelog} from '../src/transform'
import moment from 'moment'
import {Configuration, DefaultConfiguration} from '../src/configuration'
import { PullRequestInfo } from 'github-pr-collector/lib/pullRequests'
import { DefaultDiffInfo } from 'github-pr-collector/lib/commits'
jest.setTimeout(180000)
const configuration = Object.assign({}, DefaultConfiguration)
configuration.categories = [
{
title: '## 🚀 Features',
labels: ['[Feature]']
},
{
title: '## 🐛 Fixes',
labels: ['[Bug]', '[Issue]']
},
{
title: '## 🧪 Tests',
labels: ['[Test]']
},
{
title: '## 🧪 Others',
labels: ['[Other]']
}
]
// list of PRs without labels assigned (extract from title)
const mergedPullRequests: PullRequestInfo[] = []
mergedPullRequests.push(
{
number: 1,
title: '[Feature][AB-1234] - this is a PR 1 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
body: 'no magic body1 for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'merged'
},
{
number: 2,
title: '[Issue][AB-4321] - this is a PR 2 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
body: 'no magic body2 for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'merged'
},
{
number: 3,
title: '[Issue][Feature][AB-1234321] - this is a PR 3 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
body: 'no magic body3 for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'merged'
},
{
number: 4,
title: '[AB-404] - not found label',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
body: 'no magic body4 for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'merged'
}
)
const pullRequestWithLabelInBody: PullRequestInfo = {
number: 5,
title: 'label in body',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
body: '[Issue][Feature][AB-1234321] - no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'merged'
}
const openPullRequest: PullRequestInfo = {
number: 6,
title: 'Still pending open pull request',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
body: 'Some fancy body message',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'open'
}
it('Extract label from title, combined regex', async () => {
configuration.label_extractor = [
{
pattern: '.*(\\[Feature\\]|\\[Issue\\]).*',
target: '$1',
on_property: 'title'
}
]
expect(buildChangelogTest(configuration, mergedPullRequests)).toStrictEqual(
`## 🚀 Features\n\n- [Feature][AB-1234] - this is a PR 1 title message\n - PR: #1\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n\n`
)
})
it('Extract label from title and body, combined regex', async () => {
configuration.label_extractor = [
{
pattern: '.*(\\[Feature\\]|\\[Issue\\]).*',
target: '$1',
on_property: ['title', 'body']
}
]
let prs = Array.from(mergedPullRequests)
prs.push(pullRequestWithLabelInBody)
expect(buildChangelogTest(configuration, prs)).toStrictEqual(
`## 🚀 Features\n\n- [Feature][AB-1234] - this is a PR 1 title message\n - PR: #1\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n- label in body\n - PR: #5\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n\n`
)
})
it('Extract label from title, split regex', async () => {
configuration.label_extractor = [
{
pattern: '.*(\\[Feature\\]).*',
target: '$1',
on_property: 'title'
},
{
pattern: '.*(\\[Issue\\]).*',
target: '$1',
on_property: 'title'
}
]
expect(buildChangelogTest(configuration, mergedPullRequests)).toStrictEqual(
`## 🚀 Features\n\n- [Feature][AB-1234] - this is a PR 1 title message\n - PR: #1\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n`
)
})
it('Extract label from title, match', async () => {
configuration.label_extractor = [
{
pattern: '\\[Feature\\]',
on_property: 'title',
method: 'match'
},
{
pattern: '\\[Issue\\]',
on_property: 'title',
method: 'match'
}
]
expect(buildChangelogTest(configuration, mergedPullRequests)).toStrictEqual(
`## 🚀 Features\n\n- [Feature][AB-1234] - this is a PR 1 title message\n - PR: #1\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n`
)
})
it('Extract label from title, match multiple', async () => {
configuration.label_extractor = [
{
pattern: '\\[Feature\\]|\\[Issue\\]',
on_property: 'title',
method: 'match'
}
]
expect(buildChangelogTest(configuration, mergedPullRequests)).toStrictEqual(
`## 🚀 Features\n\n- [Feature][AB-1234] - this is a PR 1 title message\n - PR: #1\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n`
)
})
it('Extract label from title, match multiple, custon non matching label', async () => {
configuration.label_extractor = [
{
pattern: '\\[Feature\\]|\\[Issue\\]',
on_property: 'title',
method: 'match',
on_empty: '[Other]'
}
]
expect(buildChangelogTest(configuration, mergedPullRequests)).toStrictEqual(
`## 🚀 Features\n\n- [Feature][AB-1234] - this is a PR 1 title message\n - PR: #1\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🧪 Others\n\n- [AB-404] - not found label\n - PR: #4\n\n`
)
})
// test set of PRs with lables predefined
const pullRequestsWithLabels: PullRequestInfo[] = []
pullRequestsWithLabels.push(
{
number: 1,
title: '[ABC-1234] - this is a PR 1 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1-1',
author: 'Mike',
repoName: 'test-repo',
labels: ['feature'],
milestone: '',
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'merged'
},
{
number: 2,
title: '[ABC-4321] - this is a PR 2 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1-2',
author: 'Mike',
repoName: 'test-repo',
labels: ['issue', 'fix'],
milestone: '',
body: 'no magic body for this matter - #1',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'merged'
},
{
number: 3,
title: '[ABC-1234] - this is a PR 3 title message',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment().add(1, 'days'),
mergeCommitSha: 'sha1-3',
author: 'Mike',
repoName: 'test-repo',
labels: ['issue', 'feature', 'fix'],
milestone: '',
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'merged'
},
{
number: 4,
title: '[AB-404] - not found label',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1-4',
author: 'Mike',
repoName: 'test-repo',
labels: [''],
milestone: '',
body: 'no magic body for this matter',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'merged'
}
)
const openPullRequestsWithLabels: PullRequestInfo[] = []
openPullRequestsWithLabels.push(
{
number: 6,
title: 'Still pending open pull request (Current)',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
repoName: 'test-repo',
labels: ['feature'],
milestone: '',
body: 'Some fancy body message',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'open'
},
{
number: 7,
title: 'Still pending open pull request',
htmlURL: '',
baseBranch: '',
createdAt: moment(),
mergedAt: moment(),
mergeCommitSha: 'sha1',
author: 'Mike',
repoName: 'test-repo',
labels: [],
milestone: '',
body: 'Some fancy body message',
assignees: [],
requestedReviewers: [],
approvedReviewers: [],
status: 'open'
}
)
it('Match multiple labels exhaustive for category', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.categories = [
{
title: '## 🚀 Features and 🐛 Issues',
labels: ['Feature', 'Issue'],
exhaustive: true
},
{
title: '## 🚀 Features',
labels: ['Feature', 'Feature2'],
exhaustive: true
},
{
title: '## 🐛 Fixes',
labels: ['Issue', 'Issue2'],
exhaustive: true
}
]
expect(buildChangelogTest(customConfig, pullRequestsWithLabels)).toStrictEqual(
`## 🚀 Features and 🐛 Issues\n\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n`
)
})
it('Deduplicate duplicated PRs', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.duplicate_filter = {
pattern: '\\[ABC-....\\]',
on_property: 'title',
method: 'match'
}
expect(buildChangelogTest(customConfig, pullRequestsWithLabels)).toStrictEqual(
`## 🚀 Features\n\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [ABC-4321] - this is a PR 2 title message\n - PR: #2\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n`
)
})
it('Deduplicate duplicated PRs DESC', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.sort = 'DESC'
customConfig.duplicate_filter = {
pattern: '\\[ABC-....\\]',
on_property: 'title',
method: 'match'
}
expect(buildChangelogTest(customConfig, pullRequestsWithLabels)).toStrictEqual(
`## 🚀 Features\n\n- [ABC-1234] - this is a PR 1 title message\n - PR: #1\n\n## 🐛 Fixes\n\n- [ABC-4321] - this is a PR 2 title message\n - PR: #2\n\n`
)
})
it('Reference PRs', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.categories = [
{
title: '',
labels: []
}
]
customConfig.pr_template = "${{NUMBER}} -- ${{REFERENCED[*].number}}"
customConfig.reference = {
pattern: '.*\ \#(.).*', // matches the 1 from "abcdefg #1 adfasdf"
on_property: 'body',
method: 'replace',
target: '$1'
}
expect(buildChangelogTest(customConfig, pullRequestsWithLabels)).toStrictEqual(
`1 -- 2\n4 -- \n3 -- \n\n`
)
})
it('Use empty_content for empty category', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.categories = [
{
title: '## 🚀 Features and 🐛 Issues',
labels: ['Never-Matching-Category'],
empty_content: '- No PRs in this category'
},
{
title: '## 🚀 Features',
labels: ['Feature']
}
]
expect(buildChangelogTest(customConfig, pullRequestsWithLabels)).toStrictEqual(
`## 🚀 Features and 🐛 Issues\n\n- No PRs in this category\n\n## 🚀 Features\n\n- [ABC-1234] - this is a PR 1 title message\n - PR: #1\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n`
)
})
it('Commit SHA-1 in commitMode', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.sort = 'DESC'
customConfig.pr_template = '${{MERGE_SHA}}'
const resultChangelog = buildChangelog(DefaultDiffInfo, pullRequestsWithLabels, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: {name: '1.0.0'},
toTag: {name: '2.0.0'},
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: true,
configuration: customConfig
})
expect(resultChangelog).toStrictEqual(`## 🚀 Features\n\nsha1-3\nsha1-1\n\n## 🐛 Fixes\n\nsha1-3\nsha1-2\n\n`)
})
it('Release Diff', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.template = '${{RELEASE_DIFF}}\n${{DAYS_SINCE}}'
const resultChangelog = buildChangelog(DefaultDiffInfo, pullRequestsWithLabels, {
owner: 'mikepenz',
repo: 'release-changelog-builder-action',
fromTag: {name: 'v2.8.0'},
toTag: {name: 'v2.8.1'},
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: true,
fetchReviews: false,
commitMode: true,
configuration: customConfig
})
expect(resultChangelog).toStrictEqual(`https://github.com/mikepenz/release-changelog-builder-action/compare/v2.8.0...v2.8.1\n`)
})
it('Use exclude labels to not include a PR within a category.', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.categories = [
{
title: '## 🚀 Features and 🐛 Issues',
labels: ['Feature', 'Issue'],
exhaustive: true
},
{
title: '## 🚀 Features and 🐛 Issues But No 🐛 Fixes',
labels: ['Feature', 'Issue'],
exclude_labels: ['Fix'],
exhaustive: true
},
{
title: '## 🚀 Features and/or 🐛 Issues But No 🐛 Fixes',
labels: ['Feature', 'Issue'],
exclude_labels: ['Fix']
}
]
expect(buildChangelogTest(customConfig, pullRequestsWithLabels)).toStrictEqual(
`## 🚀 Features and 🐛 Issues\n\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n## 🚀 Features and/or 🐛 Issues But No 🐛 Fixes\n\n- [ABC-1234] - this is a PR 1 title message\n - PR: #1\n\n`
)
})
it('Extract custom placeholder from PR body and replace in global template', async () => {
const customConfig = Object.assign({}, configuration)
customConfig.custom_placeholders = [
{
name: 'C_PLACEHOLDER_1',
source: 'BODY',
transformer: {
pattern: '.+ (b....).+',
target: '- $1'
}
},
{
name: 'C_PLACEHOLER_2',
source: 'BODY',
transformer: {
pattern: '.+ b(....).+',
target: '\n- $1'
}
},
{
name: 'C_PLACEHOLER_3',
source: 'BODY',
transformer: {
pattern: '.+(body1).+',
target: '$1'
}
},
{
name: 'C_PLACEHOLER_4',
source: 'BODY',
transformer: {
pattern: '.+(body-never-matches).+',
target: '$1'
}
}
]
customConfig.template =
'${{CHANGELOG}}\n\n${{C_PLACEHOLER_2[2]}}\n\n${{C_PLACEHOLER_2[*]}}${{C_PLACEHOLDER_1[7]}}${{C_PLACEHOLER_2[1493]}}${{C_PLACEHOLER_4[*]}}${{C_PLACEHOLER_4[0]}}${{C_PLACEHOLER_3[1]}}'
customConfig.pr_template = '${{BODY}} ----> ${{C_PLACEHOLDER_1}}${{C_PLACEHOLER_3}}'
expect(buildChangelogTest(customConfig, mergedPullRequests)).toStrictEqual(
`## 🚀 Features\n\nno magic body1 for this matter ----> - body1body1\nno magic body3 for this matter ----> - body3\n\n## 🐛 Fixes\n\nno magic body2 for this matter ----> - body2\nno magic body3 for this matter ----> - body3\n\n## 🧪 Others\n\nno magic body4 for this matter ----> - body4\n\n\n\n\n- ody3\n\n\n- ody1\n- ody2\n- ody3\n- ody4`
)
})
it('Use Rules to include a PR within a Category.', async () => {
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.categories = [
{
title: '## 🚀 Features But No 🐛 Fixes and only merged with a title containing `[ABC-1234]`',
labels: ['Feature'],
exclude_labels: ['Fix'],
rules: [
{
pattern: '[ABC-1234]',
on_property: 'title'
},
{
pattern: 'merged',
on_property: 'status'
}
],
exhaustive: true
}
]
expect(buildChangelogTest(customConfig, pullRequestsWithLabels)).toStrictEqual(
`## 🚀 Features But No 🐛 Fixes and only merged with a title containing \`[ABC-1234]\`\n\n- [ABC-1234] - this is a PR 1 title message\n - PR: #1\n\n`
)
})
it('Use Rules to get all open PRs in a Category.', async () => {
let prs = Array.from(pullRequestsWithLabels)
prs.push(openPullRequest)
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.categories = [
{
title: '## Open PRs only',
rules: [
{
pattern: 'open',
on_property: 'status'
}
]
}
]
expect(buildChangelogTest(customConfig, prs)).toStrictEqual(`## Open PRs only\n\n- Still pending open pull request\n - PR: #6\n\n`)
})
it('Use Rules to get current open PR and merged categorised.', async () => {
let prs = Array.from(pullRequestsWithLabels)
prs = prs.concat(Array.from(openPullRequestsWithLabels))
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.categories = [
{
title: '## 🚀 Features',
labels: ['Feature'],
rules: [
{
pattern: '6',
on_property: 'number'
},
{
pattern: 'merged',
on_property: 'status'
}
],
exhaustive: true,
exhaustive_rules: false
},
{
title: '## 🐛 Issues',
labels: ['Issue'],
rules: [
{
pattern: 'merged',
on_property: 'status'
}
],
exhaustive: true
}
]
expect(buildChangelogTest(customConfig, prs)).toStrictEqual(
`## 🚀 Features\n\n- [ABC-1234] - this is a PR 1 title message\n - PR: #1\n- Still pending open pull request (Current)\n - PR: #6\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Issues\n\n- [ABC-4321] - this is a PR 2 title message\n - PR: #2\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n`
)
})
it('Use Rules to get all open PRs in one Category and merged categorised.', async () => {
let prs = Array.from(pullRequestsWithLabels)
prs.push(openPullRequest)
const customConfig = Object.assign({}, DefaultConfiguration)
customConfig.categories = [
{
title: '## Open PRs only',
rules: [
{
pattern: 'open',
on_property: 'status'
}
]
},
{
title: '## 🚀 Features and 🐛 Issues',
labels: ['Feature', 'Issue'],
rules: [
{
pattern: 'merged',
on_property: 'status'
}
],
exhaustive: true
}
]
expect(buildChangelogTest(customConfig, prs)).toStrictEqual(
`## Open PRs only\n\n- Still pending open pull request\n - PR: #6\n\n## 🚀 Features and 🐛 Issues\n\n- [ABC-1234] - this is a PR 3 title message\n - PR: #3\n\n`
)
})
function buildChangelogTest(config: Configuration, prs: PullRequestInfo[]): string {
return buildChangelog(DefaultDiffInfo, prs, {
owner: 'mikepenz',
repo: 'test-repo',
fromTag: {name: '1.0.0'},
toTag: {name: '2.0.0'},
includeOpen: false,
failOnError: false,
fetchReviewers: false,
fetchReleaseInformation: false,
fetchReviews: false,
commitMode: false,
configuration: config
})
}