1- import { promisify } from 'util' ;
21import test from 'ava' ;
32import { stub } from 'sinon' ;
43import commitAnalyzer from '..' ;
@@ -11,7 +10,7 @@ test.beforeEach(t => {
1110
1211test ( 'Parse with "conventional-changelog-angular" by default' , async t => {
1312 const commits = [ { message : 'fix(scope1): First fix' } , { message : 'feat(scope2): Second feature' } ] ;
14- const releaseType = await promisify ( commitAnalyzer ) ( { } , { commits, logger : t . context . logger } ) ;
13+ const releaseType = await commitAnalyzer ( { } , { commits, logger : t . context . logger } ) ;
1514
1615 t . is ( releaseType , 'minor' ) ;
1716 t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 0 ] . message ) ) ;
@@ -23,7 +22,7 @@ test('Parse with "conventional-changelog-angular" by default', async t => {
2322
2423test ( 'Accept "preset" option' , async t => {
2524 const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
26- const releaseType = await promisify ( commitAnalyzer ) ( { preset : 'eslint' } , { commits, logger : t . context . logger } ) ;
25+ const releaseType = await commitAnalyzer ( { preset : 'eslint' } , { commits, logger : t . context . logger } ) ;
2726
2827 t . is ( releaseType , 'minor' ) ;
2928 t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 0 ] . message ) ) ;
@@ -35,7 +34,7 @@ test('Accept "preset" option', async t => {
3534
3635test ( 'Accept "config" option' , async t => {
3736 const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
38- const releaseType = await promisify ( commitAnalyzer ) (
37+ const releaseType = await commitAnalyzer (
3938 { config : 'conventional-changelog-eslint' } ,
4039 { commits, logger : t . context . logger }
4140 ) ;
@@ -53,7 +52,7 @@ test('Accept a "parseOpts" object as option', async t => {
5352 { message : '%%BUGFIX%% First fix (fixes #123)' } ,
5453 { message : '%%FEATURE%% Second feature (fixes #456)' } ,
5554 ] ;
56- const releaseType = await promisify ( commitAnalyzer ) (
55+ const releaseType = await commitAnalyzer (
5756 { parserOpts : { headerPattern : / ^ % % ( .* ?) % % ( .* ) $ / , headerCorrespondence : [ 'tag' , 'shortDesc' ] } } ,
5857 { commits, logger : t . context . logger }
5958 ) ;
@@ -68,7 +67,7 @@ test('Accept a "parseOpts" object as option', async t => {
6867
6968test ( 'Accept a partial "parseOpts" object as option' , async t => {
7069 const commits = [ { message : '%%fix%% First fix (fixes #123)' } , { message : '%%Update%% Second feature (fixes #456)' } ] ;
71- const releaseType = await promisify ( commitAnalyzer ) (
70+ const releaseType = await commitAnalyzer (
7271 {
7372 config : 'conventional-changelog-eslint' ,
7473 parserOpts : { headerPattern : / ^ % % ( .* ?) % % ( .* ) $ / , headerCorrespondence : [ 'type' , 'shortDesc' ] } ,
@@ -86,7 +85,7 @@ test('Accept a partial "parseOpts" object as option', async t => {
8685
8786test ( 'Accept a "releaseRules" option that reference a requierable module' , async t => {
8887 const commits = [ { message : 'fix(scope1): First fix' } , { message : 'feat(scope2): Second feature' } ] ;
89- const releaseType = await promisify ( commitAnalyzer ) (
88+ const releaseType = await commitAnalyzer (
9089 { releaseRules : './test/fixtures/release-rules' } ,
9190 { commits, logger : t . context . logger }
9291 ) ;
@@ -104,7 +103,7 @@ test('Return "major" if there is a breaking change, using default releaseRules',
104103 { message : 'Fix: First fix (fixes #123)' } ,
105104 { message : 'Update: Second feature (fixes #456) \n\n BREAKING CHANGE: break something' } ,
106105 ] ;
107- const releaseType = await promisify ( commitAnalyzer ) ( { preset : 'eslint' } , { commits, logger : t . context . logger } ) ;
106+ const releaseType = await commitAnalyzer ( { preset : 'eslint' } , { commits, logger : t . context . logger } ) ;
108107
109108 t . is ( releaseType , 'major' ) ;
110109 t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 0 ] . message ) ) ;
@@ -116,7 +115,7 @@ test('Return "major" if there is a breaking change, using default releaseRules',
116115
117116test ( 'Return "patch" if there is only types set to "patch", using default releaseRules' , async t => {
118117 const commits = [ { message : 'fix: First fix (fixes #123)' } , { message : 'perf: perf improvement' } ] ;
119- const releaseType = await promisify ( commitAnalyzer ) ( { } , { commits, logger : t . context . logger } ) ;
118+ const releaseType = await commitAnalyzer ( { } , { commits, logger : t . context . logger } ) ;
120119
121120 t . is ( releaseType , 'patch' ) ;
122121 t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 0 ] . message ) ) ;
@@ -128,7 +127,7 @@ test('Return "patch" if there is only types set to "patch", using default releas
128127
129128test ( 'Allow to use regex in "releaseRules" configuration' , async t => {
130129 const commits = [ { message : 'Chore: First chore (fixes #123)' } , { message : 'Docs: update README (fixes #456)' } ] ;
131- const releaseType = await promisify ( commitAnalyzer ) (
130+ const releaseType = await commitAnalyzer (
132131 {
133132 preset : 'eslint' ,
134133 releaseRules : [ { tag : 'Chore' , release : 'patch' } , { message : '/README/' , release : 'minor' } ] ,
@@ -146,7 +145,7 @@ test('Allow to use regex in "releaseRules" configuration', async t => {
146145
147146test ( 'Return "null" if no rule match' , async t => {
148147 const commits = [ { message : 'doc: doc update' } , { message : 'chore: Chore' } ] ;
149- const releaseType = await promisify ( commitAnalyzer ) ( { } , { commits, logger : t . context . logger } ) ;
148+ const releaseType = await commitAnalyzer ( { } , { commits, logger : t . context . logger } ) ;
150149
151150 t . is ( releaseType , null ) ;
152151 t . true ( t . context . log . calledWith ( 'Analyzing commit: %s' , commits [ 0 ] . message ) ) ;
@@ -158,7 +157,7 @@ test('Return "null" if no rule match', async t => {
158157
159158test ( 'Process rules in order and apply highest match' , async t => {
160159 const commits = [ { message : 'Chore: First chore (fixes #123)' } , { message : 'Docs: update README (fixes #456)' } ] ;
161- const releaseType = await promisify ( commitAnalyzer ) (
160+ const releaseType = await commitAnalyzer (
162161 { preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'minor' } , { tag : 'Chore' , release : 'patch' } ] } ,
163162 { commits, logger : t . context . logger }
164163 ) ;
@@ -176,7 +175,7 @@ test('Process rules in order and apply highest match from config even if default
176175 { message : 'Chore: First chore (fixes #123)' } ,
177176 { message : 'Docs: update README (fixes #456) \n\n BREAKING CHANGE: break something' } ,
178177 ] ;
179- const releaseType = await promisify ( commitAnalyzer ) (
178+ const releaseType = await commitAnalyzer (
180179 { preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } , { breaking : true , release : 'minor' } ] } ,
181180 { commits, logger : t . context . logger }
182181 ) ;
@@ -191,7 +190,7 @@ test('Process rules in order and apply highest match from config even if default
191190
192191test ( 'Use default "releaseRules" if none of provided match' , async t => {
193192 const commits = [ { message : 'Chore: First chore' } , { message : 'Update: new feature' } ] ;
194- const releaseType = await promisify ( commitAnalyzer ) (
193+ const releaseType = await commitAnalyzer (
195194 { preset : 'eslint' , releaseRules : [ { tag : 'Chore' , release : 'patch' } ] } ,
196195 { commits, logger : t . context . logger }
197196 ) ;
@@ -205,42 +204,40 @@ test('Use default "releaseRules" if none of provided match', async t => {
205204} ) ;
206205
207206test ( 'Throw error if "preset" doesn`t exist' , async t => {
208- const error = await t . throws ( promisify ( commitAnalyzer ) ( { preset : 'unknown-preset' } , { } ) ) ;
207+ const error = await t . throws ( commitAnalyzer ( { preset : 'unknown-preset' } , { } ) ) ;
209208
210209 t . is ( error . code , 'MODULE_NOT_FOUND' ) ;
211210} ) ;
212211
213212test ( 'Throw error if "releaseRules" is not an Array or a String' , async t => {
214213 await t . throws (
215- promisify ( commitAnalyzer ) ( { releaseRules : { } } , { } ) ,
214+ commitAnalyzer ( { releaseRules : { } } , { } ) ,
216215 / 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 /
217216 ) ;
218217} ) ;
219218
220219test ( 'Throw error if "releaseRules" option reference a requierable module that is not an Array or a String' , async t => {
221220 await t . throws (
222- promisify ( commitAnalyzer ) ( { releaseRules : './test/fixtures/release-rules-invalid' } , { } ) ,
221+ commitAnalyzer ( { releaseRules : './test/fixtures/release-rules-invalid' } , { } ) ,
223222 / 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 /
224223 ) ;
225224} ) ;
226225
227226test ( 'Throw error if "config" doesn`t exist' , async t => {
228227 const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
229- const error = await t . throws (
230- promisify ( commitAnalyzer ) ( { config : 'unknown-config' } , { commits, logger : t . context . logger } )
231- ) ;
228+ const error = await t . throws ( commitAnalyzer ( { config : 'unknown-config' } , { commits, logger : t . context . logger } ) ) ;
232229
233230 t . is ( error . code , 'MODULE_NOT_FOUND' ) ;
234231} ) ;
235232
236233test ( 'Throw error if "releaseRules" reference invalid commit type' , async t => {
237234 await t . throws (
238- promisify ( commitAnalyzer ) ( { preset : 'eslint' , releaseRules : [ { tag : 'Update' , release : 'invalid' } ] } , { } ) ,
235+ commitAnalyzer ( { preset : 'eslint' , releaseRules : [ { tag : 'Update' , release : 'invalid' } ] } , { } ) ,
239236 / 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 : \[ ? .* \] /
240237 ) ;
241238} ) ;
242239
243240test ( 'Re-Throw error from "conventional-changelog-parser"' , async t => {
244241 const commits = [ { message : 'Fix: First fix (fixes #123)' } , { message : 'Update: Second feature (fixes #456)' } ] ;
245- await t . throws ( promisify ( commitAnalyzer ) ( { parserOpts : { headerPattern : '\\' } } , { commits, logger : t . context . logger } ) ) ;
242+ await t . throws ( commitAnalyzer ( { parserOpts : { headerPattern : '\\' } } , { commits, logger : t . context . logger } ) ) ;
246243} ) ;
0 commit comments