@@ -6,8 +6,9 @@ import * as path from 'path';
66const tmp = temporaryDir ( ) ;
77
88describe ( 'CLI Markdown files generation' , ( ) => {
9- const distFolder = tmp . name + '-markdown-files' ;
10- const fixtureFolder = tmp . name + '-markdown-fixture' ;
9+ const distFolder = path . resolve ( tmp . name + '-markdown-files' ) ;
10+ const fixtureFolder = path . resolve ( tmp . name + '-markdown-fixture' ) ;
11+ const cliPath = path . resolve ( './bin/index-cli.js' ) ;
1112
1213 describe ( 'when CHANGELOG, CONTRIBUTING, and LICENSE markdown files exist' , ( ) => {
1314 let stdoutString = undefined ;
@@ -50,14 +51,27 @@ describe('CLI Markdown files generation', () => {
5051 path . join ( fixtureFolder , 'tsconfig.json' ) ,
5152 JSON . stringify ( tsconfigContent , null , 2 )
5253 ) ;
54+
55+ fs . writeFileSync (
56+ path . join ( fixtureFolder , 'CHANGELOG.md' ) ,
57+ '# Changelog\n\n- fix: bitbucket link ([abc1234](https://bitbucket.org/team/repo/commit/abc1234))\n'
58+ ) ;
59+ fs . writeFileSync (
60+ path . join ( fixtureFolder , 'CONTRIBUTING.md' ) ,
61+ '# Contributing\n\nPlease contribute.\n'
62+ ) ;
63+ fs . writeFileSync (
64+ path . join ( fixtureFolder , 'LICENSE.md' ) ,
65+ '# License\n\nMIT\n'
66+ ) ;
5367
5468 const ls = shell ( 'node' , [
55- './bin/index-cli.js' ,
69+ cliPath ,
5670 '-p' ,
57- path . join ( fixtureFolder , 'tsconfig.json' ) ,
71+ 'tsconfig.json' ,
5872 '-d' ,
5973 distFolder
60- ] ) ;
74+ ] , { cwd : fixtureFolder } ) ;
6175
6276 if ( ls . stderr . toString ( ) !== '' ) {
6377 console . error ( `shell error: ${ ls . stderr . toString ( ) } ` ) ;
@@ -93,10 +107,19 @@ describe('CLI Markdown files generation', () => {
93107 const changelogExists = exists ( `${ distFolder } /changelog.html` ) ;
94108 expect ( changelogExists ) . to . be . true ;
95109 const changelogContent = read ( `${ distFolder } /changelog.html` ) ;
96- // Note: reads from project root CHANGELOG.md, not fixture
97110 expect ( changelogContent ) . to . contain ( 'changelog' ) ;
98111 } ) ;
99112
113+ it ( 'should normalize bitbucket commit links in changelog to /commits/' , ( ) => {
114+ const changelogContent = read ( `${ distFolder } /changelog.html` ) ;
115+ expect ( changelogContent ) . to . contain (
116+ 'https://bitbucket.org/team/repo/commits/abc1234'
117+ ) ;
118+ expect ( changelogContent ) . to . not . contain (
119+ 'https://bitbucket.org/team/repo/commit/abc1234'
120+ ) ;
121+ } ) ;
122+
100123 it ( 'should generate contributing.html page' , ( ) => {
101124 const contributingExists = exists ( `${ distFolder } /contributing.html` ) ;
102125 expect ( contributingExists ) . to . be . true ;
@@ -162,4 +185,4 @@ describe('CLI Markdown files generation', () => {
162185 expect ( menuFile ) . to . contain ( 'license.html' ) ;
163186 } ) ;
164187 } ) ;
165- } ) ;
188+ } ) ;
0 commit comments