@@ -60,6 +60,8 @@ describe('cz-customizable-ghooks', () => {
6060 { msg : 'docs(ccc): breaking change allowed\n\nBREAKING CHANGE: blah' , expectedResult : false } ,
6161 { msg : 'fix(ccc): breaking change allowed\n\nBREAKING CHANGE: blah' , expectedResult : true } ,
6262 { msg : 'feat(ccc): breaking change allowed\n\nBREAKING CHANGE: blah' , expectedResult : true } ,
63+ { msg : 'docs: type with no scope is valid' , expectedResult : true } ,
64+ { msg : 'fix(): but blank scopes are invalid' , expectedResult : false } ,
6365 { msg : 'docs(dddd): but this is ok' , expectedResult : true } ,
6466 { msg : 'feat(customScope): this ok' , expectedResult : true } ,
6567 ] ;
@@ -119,6 +121,8 @@ describe('cz-customizable-ghooks', () => {
119121 { msg : 'feat(customScope): this not ok' , expectedResult : false } ,
120122 { msg : 'docs(custom): docs has an override scope' , expectedResult : true } ,
121123 { msg : 'fix(merge): and so does fix' , expectedResult : true } ,
124+ { msg : 'fix: and so does fix with no scope' , expectedResult : true } ,
125+ { msg : 'fix(): but blank scopes are invalid' , expectedResult : false } ,
122126 { msg : 'docs(invalidCustom): not a valid custom scope' , expectedResult : false } ,
123127 ] ;
124128
@@ -152,7 +156,6 @@ describe('cz-customizable-ghooks', () => {
152156 { value : 'fix' , name : 'fix: A bug fix' } ,
153157 { value : 'docs' , name : 'docs: Documentation only changes' } ,
154158 ] ,
155-
156159 scopeOverrides : {
157160 fix : baseScopes ,
158161 docs : baseScopes . concat ( { name : 'custom' } ) ,
@@ -169,6 +172,8 @@ describe('cz-customizable-ghooks', () => {
169172 { msg : 'docs(custom): this has an override scope' , expectedResult : true } ,
170173 { msg : 'feat(merge): no scopes for feature' , expectedResult : false } ,
171174 { msg : 'docs(invalidCustom): not a valid custom scope' , expectedResult : false } ,
175+ { msg : 'docs(): but blank scopes are invalid' , expectedResult : false } ,
176+ { msg : 'docs: the scope is in fact optional' , expectedResult : true } ,
172177 ] ;
173178
174179 let consoleData = '' ;
@@ -451,6 +456,30 @@ describe('cz-customizable-ghooks', () => {
451456 } ) ;
452457
453458
459+ it ( 'should try to append to the incorrect-log-file when the commit message is invalid()' , ( done ) => {
460+ createCommitMessageFile ( 'foo' ) ;
461+
462+ let fileNameThatIsAppended ;
463+ let fileDataThatIsAppended ;
464+
465+ revert2 = module . __set__ ( {
466+ 'validateMessage' : ( ) => false ,
467+ 'fs.appendFile' : ( name , data , callback ) => {
468+ fileNameThatIsAppended = name ;
469+ fileDataThatIsAppended = data ;
470+ callback ( ) ;
471+ } ,
472+ } ) ;
473+
474+ function cb ( ) {
475+ assert ( fileNameThatIsAppended . indexOf ( 'test/COMMIT_MSG' ) !== - 1 ) ;
476+ assert . equal ( fileDataThatIsAppended , 'foo\n' ) ;
477+ done ( ) ;
478+ }
479+ module . processCLI ( commitMsgFileName , cb ) ;
480+ } ) ;
481+
482+
454483 it ( 'should display "Commit message is valid." when the commit message is valid' , ( done ) => {
455484 createCommitMessageFile ( 'feat(a): something' ) ;
456485
0 commit comments