@@ -12,6 +12,7 @@ import {
12
12
createNoopWriteStream ,
13
13
} from '../tests/unit/helpers.js' ;
14
14
import {
15
+ formatChangelog ,
15
16
readMonorepoRootPackage ,
16
17
readMonorepoWorkspacePackage ,
17
18
updatePackage ,
@@ -494,11 +495,15 @@ describe('package', () => {
494
495
## [Unreleased]
495
496
496
497
## [2.0.0]
498
+
497
499
### Uncategorized
500
+
498
501
- Add isNewFunction ([#2](https://repo.url/compare/package/pull/2))
499
502
500
503
## [1.0.0] - 2020-01-01
504
+
501
505
### Changed
506
+
502
507
- Something else
503
508
504
509
[Unreleased]: https://repo.url/compare/[email protected]
@@ -572,6 +577,7 @@ describe('package', () => {
572
577
projectRootDirectory : sandbox . directoryPath ,
573
578
repoUrl : 'https://repo.url' ,
574
579
tagPrefixes : [ 'package@' , 'v' ] ,
580
+ formatter : formatChangelog ,
575
581
} )
576
582
. mockResolvedValue ( 'new changelog' ) ;
577
583
await fs . promises . writeFile ( changelogPath , 'existing changelog' ) ;
@@ -610,6 +616,7 @@ describe('package', () => {
610
616
projectRootDirectory : sandbox . directoryPath ,
611
617
repoUrl : 'https://repo.url' ,
612
618
tagPrefixes : [ 'package@' , 'v' ] ,
619
+ formatter : formatChangelog ,
613
620
} )
614
621
. mockResolvedValue ( undefined ) ;
615
622
await fs . promises . writeFile ( changelogPath , 'existing changelog' ) ;
@@ -673,4 +680,30 @@ describe('package', () => {
673
680
} ) ;
674
681
} ) ;
675
682
} ) ;
683
+
684
+ describe ( 'formatChangelog' , ( ) => {
685
+ it ( 'formats a changelog' , ( ) => {
686
+ const unformattedChangelog = `# Changelog
687
+ ## 1.0.0
688
+
689
+ - Some change
690
+ ## 0.0.1
691
+
692
+ - Some other change
693
+ ` ;
694
+
695
+ expect ( formatChangelog ( unformattedChangelog ) ) . toMatchInlineSnapshot ( `
696
+ "# Changelog
697
+
698
+ ## 1.0.0
699
+
700
+ - Some change
701
+
702
+ ## 0.0.1
703
+
704
+ - Some other change
705
+ "
706
+ ` ) ;
707
+ } ) ;
708
+ } ) ;
676
709
} ) ;
0 commit comments