@@ -11,7 +11,10 @@ test.beforeEach(t => {
1111} ) ;
1212
1313test ( 'Parse with "conventional-changelog-angular" by default' , async t => {
14- const commits = [ { message : 'fix(scope1): First fix' } , { message : 'feat(scope2): Second feature' } ] ;
14+ const commits = [
15+ { hash : '123' , message : 'fix(scope1): First fix' } ,
16+ { hash : '456' , message : 'feat(scope2): Second feature' } ,
17+ ] ;
1518 const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
1619
1720 t . is ( releaseType , 'minor' ) ;
@@ -23,7 +26,10 @@ test('Parse with "conventional-changelog-angular" by default', async t => {
2326} ) ;
2427
2528test ( 'Accept "preset" option' , async t => {
26- const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
29+ const commits = [
30+ { hash : '123' , message : 'Fix: First fix (fixes #123)' } ,
31+ { hash : '456' , message : 'Update: Second feature (fixes #456)' } ,
32+ ] ;
2733 const releaseType = await analyzeCommits ( { preset : 'eslint' } , { cwd, commits, logger : t . context . logger } ) ;
2834
2935 t . is ( releaseType , 'minor' ) ;
@@ -35,7 +41,10 @@ test('Accept "preset" option', async t => {
3541} ) ;
3642
3743test ( 'Accept "config" option' , async t => {
38- const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
44+ const commits = [
45+ { hash : '123' , message : 'Fix: First fix (fixes #123)' } ,
46+ { hash : '456' , message : 'Update: Second feature (fixes #456)' } ,
47+ ] ;
3948 const releaseType = await analyzeCommits (
4049 { config : 'conventional-changelog-eslint' } ,
4150 { cwd, commits, logger : t . context . logger }
@@ -51,8 +60,8 @@ test('Accept "config" option', async t => {
5160
5261test ( 'Accept a "parseOpts" object as option' , async t => {
5362 const commits = [
54- { message : '%%BUGFIX%% First fix (fixes #123)' } ,
55- { message : '%%FEATURE%% Second feature (fixes #456)' } ,
63+ { hash : '123' , message : '%%BUGFIX%% First fix (fixes #123)' } ,
64+ { hash : '456' , message : '%%FEATURE%% Second feature (fixes #456)' } ,
5665 ] ;
5766 const releaseType = await analyzeCommits (
5867 { parserOpts : { headerPattern : / ^ % % ( .* ?) % % ( .* ) $ / , headerCorrespondence : [ 'tag' , 'shortDesc' ] } } ,
@@ -68,7 +77,10 @@ test('Accept a "parseOpts" object as option', async t => {
6877} ) ;
6978
7079test ( 'Accept a partial "parseOpts" object as option' , async t => {
71- const commits = [ { message : '%%fix%% First fix (fixes #123)' } , { message : '%%Update%% Second feature (fixes #456)' } ] ;
80+ const commits = [
81+ { hash : '123' , message : '%%fix%% First fix (fixes #123)' } ,
82+ { hash : '456' , message : '%%Update%% Second feature (fixes #456)' } ,
83+ ] ;
7284 const releaseType = await analyzeCommits (
7385 {
7486 config : 'conventional-changelog-eslint' ,
@@ -100,7 +112,10 @@ test('Exclude commits if they have a matching revert commits', async t => {
100112} ) ;
101113
102114test ( 'Accept a "releaseRules" option that reference a requierable module' , async t => {
103- const commits = [ { message : 'fix(scope1): First fix' } , { message : 'feat(scope2): Second feature' } ] ;
115+ const commits = [
116+ { hash : '123' , message : 'fix(scope1): First fix' } ,
117+ { hash : '456' , message : 'feat(scope2): Second feature' } ,
118+ ] ;
104119 const releaseType = await analyzeCommits (
105120 { releaseRules : './test/fixtures/release-rules' } ,
106121 { cwd, commits, logger : t . context . logger }
@@ -116,8 +131,8 @@ test('Accept a "releaseRules" option that reference a requierable module', async
116131
117132test ( 'Return "major" if there is a breaking change, using default releaseRules' , async t => {
118133 const commits = [
119- { message : 'Fix: First fix (fixes #123)' } ,
120- { message : 'Update: Second feature (fixes #456) \n\n BREAKING CHANGE: break something' } ,
134+ { hash : '123' , message : 'Fix: First fix (fixes #123)' } ,
135+ { hash : '456' , message : 'Update: Second feature (fixes #456) \n\n BREAKING CHANGE: break something' } ,
121136 ] ;
122137 const releaseType = await analyzeCommits ( { preset : 'eslint' } , { cwd, commits, logger : t . context . logger } ) ;
123138
@@ -130,7 +145,10 @@ test('Return "major" if there is a breaking change, using default releaseRules',
130145} ) ;
131146
132147test ( 'Return "patch" if there is only types set to "patch", using default releaseRules' , async t => {
133- const commits = [ { message : 'fix: First fix (fixes #123)' } , { message : 'perf: perf improvement' } ] ;
148+ const commits = [
149+ { hash : '123' , message : 'fix: First fix (fixes #123)' } ,
150+ { hash : '456' , message : 'perf: perf improvement' } ,
151+ ] ;
134152 const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
135153
136154 t . is ( releaseType , 'patch' ) ;
@@ -142,7 +160,10 @@ test('Return "patch" if there is only types set to "patch", using default releas
142160} ) ;
143161
144162test ( 'Allow to use regex in "releaseRules" configuration' , async t => {
145- const commits = [ { message : 'Chore: First chore (fixes #123)' } , { message : 'Docs: update README (fixes #456)' } ] ;
163+ const commits = [
164+ { hash : '123' , message : 'Chore: First chore (fixes #123)' } ,
165+ { hash : '456' , message : 'Docs: update README (fixes #456)' } ,
166+ ] ;
146167 const releaseType = await analyzeCommits (
147168 { preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } , { message : '/README/' , release : 'minor' } ] } ,
148169 { cwd, commits, logger : t . context . logger }
@@ -157,7 +178,7 @@ test('Allow to use regex in "releaseRules" configuration', async t => {
157178} ) ;
158179
159180test ( 'Return "null" if no rule match' , async t => {
160- const commits = [ { message : 'doc: doc update' } , { message : 'chore: Chore' } ] ;
181+ const commits = [ { hash : '123' , message : 'doc: doc update' } , { hash : '456' , message : 'chore: Chore' } ] ;
161182 const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
162183
163184 t . is ( releaseType , null ) ;
@@ -169,7 +190,10 @@ test('Return "null" if no rule match', async t => {
169190} ) ;
170191
171192test ( 'Process rules in order and apply highest match' , async t => {
172- const commits = [ { message : 'Chore: First chore (fixes #123)' } , { message : 'Docs: update README (fixes #456)' } ] ;
193+ const commits = [
194+ { hash : '123' , message : 'Chore: First chore (fixes #123)' } ,
195+ { hash : '456' , message : 'Docs: update README (fixes #456)' } ,
196+ ] ;
173197 const releaseType = await analyzeCommits (
174198 { preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'minor' } , { tag : 'Chore' , release : 'patch' } ] } ,
175199 { cwd, commits, logger : t . context . logger }
@@ -185,8 +209,8 @@ test('Process rules in order and apply highest match', async t => {
185209
186210test ( 'Process rules in order and apply highest match from config even if default has an higher match' , async t => {
187211 const commits = [
188- { message : 'Chore: First chore (fixes #123)' } ,
189- { message : 'Docs: update README (fixes #456) \n\n BREAKING CHANGE: break something' } ,
212+ { hash : '123' , message : 'Chore: First chore (fixes #123)' } ,
213+ { hash : '456' , message : 'Docs: update README (fixes #456) \n\n BREAKING CHANGE: break something' } ,
190214 ] ;
191215 const releaseType = await analyzeCommits (
192216 { preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } , { breaking : true , release : 'minor' } ] } ,
@@ -202,7 +226,7 @@ test('Process rules in order and apply highest match from config even if default
202226} ) ;
203227
204228test ( 'Allow to overwrite default "releaseRules" with "false"' , async t => {
205- const commits = [ { message : 'chore: First chore' } , { message : 'feat: new feature' } ] ;
229+ const commits = [ { hash : '123' , message : 'chore: First chore' } , { hash : '456' , message : 'feat: new feature' } ] ;
206230 const releaseType = await analyzeCommits (
207231 { preset : 'angular' , releaseRules : [ { type : 'feat' , release : false } ] } ,
208232 { cwd, commits, logger : t . context . logger }
@@ -217,7 +241,7 @@ test('Allow to overwrite default "releaseRules" with "false"', async t => {
217241} ) ;
218242
219243test ( 'Commits with an associated custom release type have higher priority than commits with release "false"' , async t => {
220- const commits = [ { message : 'feat: Feature to skip' } , { message : 'docs: update README' } ] ;
244+ const commits = [ { hash : '123' , message : 'feat: Feature to skip' } , { hash : '456' , message : 'docs: update README' } ] ;
221245 const releaseType = await analyzeCommits (
222246 { preset : 'angular' , releaseRules : [ { type : 'feat' , release : false } , { type : 'docs' , release : 'patch' } ] } ,
223247 { cwd, commits, logger : t . context . logger }
@@ -232,7 +256,7 @@ test('Commits with an associated custom release type have higher priority than c
232256} ) ;
233257
234258test ( 'Commits with an associated default release type have higher priority than commits with release "false"' , async t => {
235- const commits = [ { message : 'feat: new feature' } , { message : 'fix: new Fix' } ] ;
259+ const commits = [ { hash : '123' , message : 'feat: new feature' } , { hash : '456' , message : 'fix: new Fix' } ] ;
236260 const releaseType = await analyzeCommits (
237261 { preset : 'angular' , releaseRules : [ { type : 'feat' , release : false } ] } ,
238262 { cwd, commits, logger : t . context . logger }
@@ -247,7 +271,7 @@ test('Commits with an associated default release type have higher priority than
247271} ) ;
248272
249273test ( 'Use default "releaseRules" if none of provided match' , async t => {
250- const commits = [ { message : 'Chore: First chore' } , { message : 'Update: new feature' } ] ;
274+ const commits = [ { hash : '123' , message : 'Chore: First chore' } , { hash : '456' , message : 'Update: new feature' } ] ;
251275 const releaseType = await analyzeCommits (
252276 { preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } ] } ,
253277 { cwd, commits, logger : t . context . logger }
@@ -261,6 +285,13 @@ test('Use default "releaseRules" if none of provided match', async t => {
261285 t . true ( t . context . log . calledWith ( 'Analysis of %s commits complete: %s release' , 2 , 'minor' ) ) ;
262286} ) ;
263287
288+ test ( 'Filter out empty commits' , async t => {
289+ const commits = [ { hash : '123' , message : '' } , { hash : '456' , message : 'fix(scope1): First fix' } ] ;
290+ const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
291+
292+ t . is ( releaseType , 'patch' ) ;
293+ } ) ;
294+
264295test ( 'Throw error if "preset" doesn`t exist' , async t => {
265296 await t . throwsAsync ( analyzeCommits ( { preset : 'unknown-preset' } , { cwd} ) , { code : 'MODULE_NOT_FOUND' } ) ;
266297} ) ;
0 commit comments