1
- import importFrom from 'import-from' ;
2
1
import parse from '.' ;
3
2
4
3
test ( 'throws when called without params' , async ( ) => {
@@ -81,10 +80,11 @@ test('uses angular grammar', async () => {
81
80
82
81
test ( 'uses custom opts parser' , async ( ) => {
83
82
const message = 'type(scope)-subject' ;
84
- const changelogOpts : any = await importFrom (
85
- __dirname ,
86
- '../fixtures/parser-preset/conventional-changelog-custom.js'
87
- ) ;
83
+ const changelogOpts = {
84
+ parserOpts : {
85
+ headerPattern : / ^ ( \w * ) (?: \( ( .* ) \) ) ? - ( .* ) $ /
86
+ }
87
+ } ;
88
88
const actual = await parse ( message , undefined , changelogOpts . parserOpts ) ;
89
89
const expected = {
90
90
body : null ,
@@ -145,13 +145,11 @@ test('supports scopes with / and empty parserOpts', async () => {
145
145
146
146
test ( 'ignores comments' , async ( ) => {
147
147
const message = 'type(some/scope): subject\n# some comment' ;
148
- const changelogOpts : any = await importFrom (
149
- process . cwd ( ) ,
150
- 'conventional-changelog-angular'
151
- ) ;
152
- const opts = Object . assign ( { } , changelogOpts . parserOpts , {
148
+ const changelogOpts = await require ( 'conventional-changelog-angular' ) ;
149
+ const opts = {
150
+ ...changelogOpts . parserOpts ,
153
151
commentChar : '#'
154
- } ) ;
152
+ } ;
155
153
const actual = await parse ( message , undefined , opts ) ;
156
154
157
155
expect ( actual . body ) . toBe ( null ) ;
@@ -162,13 +160,11 @@ test('ignores comments', async () => {
162
160
test ( 'registers inline #' , async ( ) => {
163
161
const message =
164
162
'type(some/scope): subject #reference\n# some comment\nthings #reference' ;
165
- const changelogOpts : any = await importFrom (
166
- process . cwd ( ) ,
167
- 'conventional-changelog-angular'
168
- ) ;
169
- const opts = Object . assign ( { } , changelogOpts . parserOpts , {
163
+ const changelogOpts = await require ( 'conventional-changelog-angular' ) ;
164
+ const opts = {
165
+ ...changelogOpts . parserOpts ,
170
166
commentChar : '#'
171
- } ) ;
167
+ } ;
172
168
const actual = await parse ( message , undefined , opts ) ;
173
169
174
170
expect ( actual . subject ) . toBe ( 'subject #reference' ) ;
@@ -177,13 +173,10 @@ test('registers inline #', async () => {
177
173
178
174
test ( 'parses references leading subject' , async ( ) => {
179
175
const message = '#1 some subject' ;
180
- const opts = await importFrom (
181
- process . cwd ( ) ,
182
- 'conventional-changelog-angular'
183
- ) ;
176
+ const opts = await require ( 'conventional-changelog-angular' ) ;
184
177
const {
185
178
references : [ actual ]
186
- } = await parse ( message , undefined , opts as any ) ;
179
+ } = await parse ( message , undefined , opts ) ;
187
180
188
181
expect ( actual . issue ) . toBe ( '1' ) ;
189
182
} ) ;
0 commit comments