1
1
import test from 'ava' ;
2
2
import { stub } from 'sinon' ;
3
- import commitAnalyzer from '..' ;
3
+ import { analyzeCommits } from '..' ;
4
4
5
5
const cwd = process . cwd ( ) ;
6
6
@@ -12,7 +12,7 @@ test.beforeEach(t => {
12
12
13
13
test ( 'Parse with "conventional-changelog-angular" by default' , async t => {
14
14
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 } ) ;
16
16
17
17
t . is ( releaseType , 'minor' ) ;
18
18
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 => {
24
24
25
25
test ( 'Accept "preset" option' , async t => {
26
26
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 } ) ;
28
28
29
29
t . is ( releaseType , 'minor' ) ;
30
30
t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 0 ] . message ) ) ;
@@ -36,7 +36,7 @@ test('Accept "preset" option', async t => {
36
36
37
37
test ( 'Accept "config" option' , async t => {
38
38
const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
39
- const releaseType = await commitAnalyzer (
39
+ const releaseType = await analyzeCommits (
40
40
{ config : 'conventional-changelog-eslint' } ,
41
41
{ cwd, commits, logger : t . context . logger }
42
42
) ;
@@ -54,7 +54,7 @@ test('Accept a "parseOpts" object as option', async t => {
54
54
{ message : '%%BUGFIX%% First fix (fixes #123)' } ,
55
55
{ message : '%%FEATURE%% Second feature (fixes #456)' } ,
56
56
] ;
57
- const releaseType = await commitAnalyzer (
57
+ const releaseType = await analyzeCommits (
58
58
{ parserOpts : { headerPattern : / ^ % % ( .* ?) % % ( .* ) $ / , headerCorrespondence : [ 'tag' , 'shortDesc' ] } } ,
59
59
{ cwd, commits, logger : t . context . logger }
60
60
) ;
@@ -69,7 +69,7 @@ test('Accept a "parseOpts" object as option', async t => {
69
69
70
70
test ( 'Accept a partial "parseOpts" object as option' , async t => {
71
71
const commits = [ { message : '%%fix%% First fix (fixes #123)' } , { message : '%%Update%% Second feature (fixes #456)' } ] ;
72
- const releaseType = await commitAnalyzer (
72
+ const releaseType = await analyzeCommits (
73
73
{
74
74
config : 'conventional-changelog-eslint' ,
75
75
parserOpts : { headerPattern : / ^ % % ( .* ?) % % ( .* ) $ / , headerCorrespondence : [ 'type' , 'shortDesc' ] } ,
@@ -91,7 +91,7 @@ test('Exclude commits if they have a matching revert commits', async t => {
91
91
{ hash : '456' , message : 'revert: feat(scope): First feature\n\nThis reverts commit 123.\n' } ,
92
92
{ message : 'fix(scope): First fix' } ,
93
93
] ;
94
- const releaseType = await commitAnalyzer ( { } , { cwd, commits, logger : t . context . logger } ) ;
94
+ const releaseType = await analyzeCommits ( { } , { cwd, commits, logger : t . context . logger } ) ;
95
95
96
96
t . is ( releaseType , 'patch' ) ;
97
97
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 => {
101
101
102
102
test ( 'Accept a "releaseRules" option that reference a requierable module' , async t => {
103
103
const commits = [ { message : 'fix(scope1): First fix' } , { message : 'feat(scope2): Second feature' } ] ;
104
- const releaseType = await commitAnalyzer (
104
+ const releaseType = await analyzeCommits (
105
105
{ releaseRules : './test/fixtures/release-rules' } ,
106
106
{ cwd, commits, logger : t . context . logger }
107
107
) ;
@@ -119,7 +119,7 @@ test('Return "major" if there is a breaking change, using default releaseRules',
119
119
{ message : 'Fix: First fix (fixes #123)' } ,
120
120
{ message : 'Update: Second feature (fixes #456) \n\n BREAKING CHANGE: break something' } ,
121
121
] ;
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 } ) ;
123
123
124
124
t . is ( releaseType , 'major' ) ;
125
125
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',
131
131
132
132
test ( 'Return "patch" if there is only types set to "patch", using default releaseRules' , async t => {
133
133
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 } ) ;
135
135
136
136
t . is ( releaseType , 'patch' ) ;
137
137
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
143
143
144
144
test ( 'Allow to use regex in "releaseRules" configuration' , async t => {
145
145
const commits = [ { message : 'Chore: First chore (fixes #123)' } , { message : 'Docs: update README (fixes #456)' } ] ;
146
- const releaseType = await commitAnalyzer (
146
+ const releaseType = await analyzeCommits (
147
147
{ preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } , { message : '/README/' , release : 'minor' } ] } ,
148
148
{ cwd, commits, logger : t . context . logger }
149
149
) ;
@@ -158,7 +158,7 @@ test('Allow to use regex in "releaseRules" configuration', async t => {
158
158
159
159
test ( 'Return "null" if no rule match' , async t => {
160
160
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 } ) ;
162
162
163
163
t . is ( releaseType , null ) ;
164
164
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 => {
170
170
171
171
test ( 'Process rules in order and apply highest match' , async t => {
172
172
const commits = [ { message : 'Chore: First chore (fixes #123)' } , { message : 'Docs: update README (fixes #456)' } ] ;
173
- const releaseType = await commitAnalyzer (
173
+ const releaseType = await analyzeCommits (
174
174
{ preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'minor' } , { tag : 'Chore' , release : 'patch' } ] } ,
175
175
{ cwd, commits, logger : t . context . logger }
176
176
) ;
@@ -188,7 +188,7 @@ test('Process rules in order and apply highest match from config even if default
188
188
{ message : 'Chore: First chore (fixes #123)' } ,
189
189
{ message : 'Docs: update README (fixes #456) \n\n BREAKING CHANGE: break something' } ,
190
190
] ;
191
- const releaseType = await commitAnalyzer (
191
+ const releaseType = await analyzeCommits (
192
192
{ preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } , { breaking : true , release : 'minor' } ] } ,
193
193
{ cwd, commits, logger : t . context . logger }
194
194
) ;
@@ -203,7 +203,7 @@ test('Process rules in order and apply highest match from config even if default
203
203
204
204
test ( 'Use default "releaseRules" if none of provided match' , async t => {
205
205
const commits = [ { message : 'Chore: First chore' } , { message : 'Update: new feature' } ] ;
206
- const releaseType = await commitAnalyzer (
206
+ const releaseType = await analyzeCommits (
207
207
{ preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } ] } ,
208
208
{ cwd, commits, logger : t . context . logger }
209
209
) ;
@@ -217,40 +217,40 @@ test('Use default "releaseRules" if none of provided match', async t => {
217
217
} ) ;
218
218
219
219
test ( '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} ) ) ;
221
221
222
222
t . is ( error . code , 'MODULE_NOT_FOUND' ) ;
223
223
} ) ;
224
224
225
225
test ( 'Throw error if "releaseRules" is not an Array or a String' , async t => {
226
226
await t . throws (
227
- commitAnalyzer ( { releaseRules : { } } , { cwd} ) ,
227
+ analyzeCommits ( { releaseRules : { } } , { cwd} ) ,
228
228
/ 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 /
229
229
) ;
230
230
} ) ;
231
231
232
232
test ( 'Throw error if "releaseRules" option reference a requierable module that is not an Array or a String' , async t => {
233
233
await t . throws (
234
- commitAnalyzer ( { releaseRules : './test/fixtures/release-rules-invalid' } , { cwd} ) ,
234
+ analyzeCommits ( { releaseRules : './test/fixtures/release-rules-invalid' } , { cwd} ) ,
235
235
/ 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 /
236
236
) ;
237
237
} ) ;
238
238
239
239
test ( 'Throw error if "config" doesn`t exist' , async t => {
240
240
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 } ) ) ;
242
242
243
243
t . is ( error . code , 'MODULE_NOT_FOUND' ) ;
244
244
} ) ;
245
245
246
246
test ( 'Throw error if "releaseRules" reference invalid commit type' , async t => {
247
247
await t . throws (
248
- commitAnalyzer ( { preset : 'eslint' , releaseRules : [ { tag : 'Update' , release : 'invalid' } ] } , { cwd} ) ,
248
+ analyzeCommits ( { preset : 'eslint' , releaseRules : [ { tag : 'Update' , release : 'invalid' } ] } , { cwd} ) ,
249
249
/ 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 : \[ ? .* \] /
250
250
) ;
251
251
} ) ;
252
252
253
253
test ( 'Re-Throw error from "conventional-changelog-parser"' , async t => {
254
254
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 } ) ) ;
256
256
} ) ;
0 commit comments