11import test from 'ava' ;
22import { stub } from 'sinon' ;
3- import commitAnalyzer from '..' ;
3+ import { analyzeCommits } from '..' ;
44
55const cwd = process . cwd ( ) ;
66
@@ -12,7 +12,7 @@ test.beforeEach(t => {
1212
1313test ( 'Parse with "conventional-changelog-angular" by default' , async t => {
1414 const commits = [ { message : 'fix(scope1): First fix' } , { message : 'feat(scope2): Second feature' } ] ;
15- const releaseType = await commitAnalyzer ( { } , { cwd, commits, logger : t . context . logger } ) ;
15+ const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
1616
1717 t . is ( releaseType , 'minor' ) ;
1818 t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 0 ] . message ) ) ;
@@ -24,7 +24,7 @@ test('Parse with "conventional-changelog-angular" by default', async t => {
2424
2525test ( 'Accept "preset" option' , async t => {
2626 const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
27- const releaseType = await commitAnalyzer ( { preset : 'eslint' } , { cwd, commits, logger : t . context . logger } ) ;
27+ const releaseType = await analyzeCommits ( { preset : 'eslint' } , { cwd, commits, logger : t . context . logger } ) ;
2828
2929 t . is ( releaseType , 'minor' ) ;
3030 t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 0 ] . message ) ) ;
@@ -36,7 +36,7 @@ test('Accept "preset" option', async t => {
3636
3737test ( 'Accept "config" option' , async t => {
3838 const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
39- const releaseType = await commitAnalyzer (
39+ const releaseType = await analyzeCommits (
4040 { config : 'conventional-changelog-eslint' } ,
4141 { cwd, commits, logger : t . context . logger }
4242 ) ;
@@ -54,7 +54,7 @@ test('Accept a "parseOpts" object as option', async t => {
5454 { message : '%%BUGFIX%% First fix (fixes #123)' } ,
5555 { message : '%%FEATURE%% Second feature (fixes #456)' } ,
5656 ] ;
57- const releaseType = await commitAnalyzer (
57+ const releaseType = await analyzeCommits (
5858 { parserOpts : { headerPattern : / ^ % % ( .* ?) % % ( .* ) $ / , headerCorrespondence : [ 'tag' , 'shortDesc' ] } } ,
5959 { cwd, commits, logger : t . context . logger }
6060 ) ;
@@ -69,7 +69,7 @@ test('Accept a "parseOpts" object as option', async t => {
6969
7070test ( 'Accept a partial "parseOpts" object as option' , async t => {
7171 const commits = [ { message : '%%fix%% First fix (fixes #123)' } , { message : '%%Update%% Second feature (fixes #456)' } ] ;
72- const releaseType = await commitAnalyzer (
72+ const releaseType = await analyzeCommits (
7373 {
7474 config : 'conventional-changelog-eslint' ,
7575 parserOpts : { headerPattern : / ^ % % ( .* ?) % % ( .* ) $ / , headerCorrespondence : [ 'type' , 'shortDesc' ] } ,
@@ -91,7 +91,7 @@ test('Exclude commits if they have a matching revert commits', async t => {
9191 { hash : '456' , message : 'revert: feat(scope): First feature\n\nThis reverts commit 123.\n' } ,
9292 { message : 'fix(scope): First fix' } ,
9393 ] ;
94- const releaseType = await commitAnalyzer ( { } , { cwd, commits, logger : t . context . logger } ) ;
94+ const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
9595
9696 t . is ( releaseType , 'patch' ) ;
9797 t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 2 ] . message ) ) ;
@@ -101,7 +101,7 @@ test('Exclude commits if they have a matching revert commits', async t => {
101101
102102test ( 'Accept a "releaseRules" option that reference a requierable module' , async t => {
103103 const commits = [ { message : 'fix(scope1): First fix' } , { message : 'feat(scope2): Second feature' } ] ;
104- const releaseType = await commitAnalyzer (
104+ const releaseType = await analyzeCommits (
105105 { releaseRules : './test/fixtures/release-rules' } ,
106106 { cwd, commits, logger : t . context . logger }
107107 ) ;
@@ -119,7 +119,7 @@ test('Return "major" if there is a breaking change, using default releaseRules',
119119 { message : 'Fix: First fix (fixes #123)' } ,
120120 { message : 'Update: Second feature (fixes #456) \n\n BREAKING CHANGE: break something' } ,
121121 ] ;
122- const releaseType = await commitAnalyzer ( { preset : 'eslint' } , { cwd, commits, logger : t . context . logger } ) ;
122+ const releaseType = await analyzeCommits ( { preset : 'eslint' } , { cwd, commits, logger : t . context . logger } ) ;
123123
124124 t . is ( releaseType , 'major' ) ;
125125 t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 0 ] . message ) ) ;
@@ -131,7 +131,7 @@ test('Return "major" if there is a breaking change, using default releaseRules',
131131
132132test ( 'Return "patch" if there is only types set to "patch", using default releaseRules' , async t => {
133133 const commits = [ { message : 'fix: First fix (fixes #123)' } , { message : 'perf: perf improvement' } ] ;
134- const releaseType = await commitAnalyzer ( { } , { cwd, commits, logger : t . context . logger } ) ;
134+ const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
135135
136136 t . is ( releaseType , 'patch' ) ;
137137 t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 0 ] . message ) ) ;
@@ -143,7 +143,7 @@ test('Return "patch" if there is only types set to "patch", using default releas
143143
144144test ( 'Allow to use regex in "releaseRules" configuration' , async t => {
145145 const commits = [ { message : 'Chore: First chore (fixes #123)' } , { message : 'Docs: update README (fixes #456)' } ] ;
146- const releaseType = await commitAnalyzer (
146+ const releaseType = await analyzeCommits (
147147 { preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } , { message : '/README/' , release : 'minor' } ] } ,
148148 { cwd, commits, logger : t . context . logger }
149149 ) ;
@@ -158,7 +158,7 @@ test('Allow to use regex in "releaseRules" configuration', async t => {
158158
159159test ( 'Return "null" if no rule match' , async t => {
160160 const commits = [ { message : 'doc: doc update' } , { message : 'chore: Chore' } ] ;
161- const releaseType = await commitAnalyzer ( { } , { cwd, commits, logger : t . context . logger } ) ;
161+ const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
162162
163163 t . is ( releaseType , null ) ;
164164 t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 0 ] . message ) ) ;
@@ -170,7 +170,7 @@ test('Return "null" if no rule match', async t => {
170170
171171test ( 'Process rules in order and apply highest match' , async t => {
172172 const commits = [ { message : 'Chore: First chore (fixes #123)' } , { message : 'Docs: update README (fixes #456)' } ] ;
173- const releaseType = await commitAnalyzer (
173+ const releaseType = await analyzeCommits (
174174 { preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'minor' } , { tag : 'Chore' , release : 'patch' } ] } ,
175175 { cwd, commits, logger : t . context . logger }
176176 ) ;
@@ -188,7 +188,7 @@ test('Process rules in order and apply highest match from config even if default
188188 { message : 'Chore: First chore (fixes #123)' } ,
189189 { message : 'Docs: update README (fixes #456) \n\n BREAKING CHANGE: break something' } ,
190190 ] ;
191- const releaseType = await commitAnalyzer (
191+ const releaseType = await analyzeCommits (
192192 { preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } , { breaking : true , release : 'minor' } ] } ,
193193 { cwd, commits, logger : t . context . logger }
194194 ) ;
@@ -203,7 +203,7 @@ test('Process rules in order and apply highest match from config even if default
203203
204204test ( 'Use default "releaseRules" if none of provided match' , async t => {
205205 const commits = [ { message : 'Chore: First chore' } , { message : 'Update: new feature' } ] ;
206- const releaseType = await commitAnalyzer (
206+ const releaseType = await analyzeCommits (
207207 { preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } ] } ,
208208 { cwd, commits, logger : t . context . logger }
209209 ) ;
@@ -217,40 +217,40 @@ test('Use default "releaseRules" if none of provided match', async t => {
217217} ) ;
218218
219219test ( 'Throw error if "preset" doesn`t exist' , async t => {
220- const error = await t . throws ( commitAnalyzer ( { preset : 'unknown-preset' } , { cwd} ) ) ;
220+ const error = await t . throws ( analyzeCommits ( { preset : 'unknown-preset' } , { cwd} ) ) ;
221221
222222 t . is ( error . code , 'MODULE_NOT_FOUND' ) ;
223223} ) ;
224224
225225test ( 'Throw error if "releaseRules" is not an Array or a String' , async t => {
226226 await t . throws (
227- commitAnalyzer ( { releaseRules : { } } , { cwd} ) ,
227+ analyzeCommits ( { releaseRules : { } } , { cwd} ) ,
228228 / E r r o r i n c o m m i t - a n a l y z e r c o n f i g u r a t i o n : " r e l e a s e R u l e s " m u s t b e a n a r r a y o f r u l e s /
229229 ) ;
230230} ) ;
231231
232232test ( 'Throw error if "releaseRules" option reference a requierable module that is not an Array or a String' , async t => {
233233 await t . throws (
234- commitAnalyzer ( { releaseRules : './test/fixtures/release-rules-invalid' } , { cwd} ) ,
234+ analyzeCommits ( { releaseRules : './test/fixtures/release-rules-invalid' } , { cwd} ) ,
235235 / E r r o r i n c o m m i t - a n a l y z e r c o n f i g u r a t i o n : " r e l e a s e R u l e s " m u s t b e a n a r r a y o f r u l e s /
236236 ) ;
237237} ) ;
238238
239239test ( 'Throw error if "config" doesn`t exist' , async t => {
240240 const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
241- const error = await t . throws ( commitAnalyzer ( { config : 'unknown-config' } , { cwd, commits, logger : t . context . logger } ) ) ;
241+ const error = await t . throws ( analyzeCommits ( { config : 'unknown-config' } , { cwd, commits, logger : t . context . logger } ) ) ;
242242
243243 t . is ( error . code , 'MODULE_NOT_FOUND' ) ;
244244} ) ;
245245
246246test ( 'Throw error if "releaseRules" reference invalid commit type' , async t => {
247247 await t . throws (
248- commitAnalyzer ( { preset : 'eslint' , releaseRules : [ { tag : 'Update' , release : 'invalid' } ] } , { cwd} ) ,
248+ analyzeCommits ( { preset : 'eslint' , releaseRules : [ { tag : 'Update' , release : 'invalid' } ] } , { cwd} ) ,
249249 / E r r o r i n c o m m i t - a n a l y z e r c o n f i g u r a t i o n : " i n v a l i d " i s n o t a v a l i d r e l e a s e t y p e \. V a l i d v a l u e s a r e : \[ ? .* \] /
250250 ) ;
251251} ) ;
252252
253253test ( 'Re-Throw error from "conventional-changelog-parser"' , async t => {
254254 const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
255- await t . throws ( commitAnalyzer ( { parserOpts : { headerPattern : '\\' } } , { cwd, commits, logger : t . context . logger } ) ) ;
255+ await t . throws ( analyzeCommits ( { parserOpts : { headerPattern : '\\' } } , { cwd, commits, logger : t . context . logger } ) ) ;
256256} ) ;
0 commit comments