11import lint from './lint' ;
2+ import { RuleConfigSeverity } from '@commitlint/types' ;
23
34test ( 'throws without params' , async ( ) => {
45 const error = ( lint as any ) ( ) ;
@@ -20,21 +21,21 @@ test('positive on stub message and no rule', async () => {
2021
2122test ( 'positive on stub message and adhered rule' , async ( ) => {
2223 const actual = await lint ( 'foo: bar' , {
23- 'type-enum' : [ 2 , 'always' , [ 'foo' ] ] ,
24+ 'type-enum' : [ RuleConfigSeverity . Error , 'always' , [ 'foo' ] ] ,
2425 } ) ;
2526 expect ( actual . valid ) . toBe ( true ) ;
2627} ) ;
2728
2829test ( 'negative on stub message and broken rule' , async ( ) => {
2930 const actual = await lint ( 'foo: bar' , {
30- 'type-enum' : [ 2 , 'never' , [ 'foo' ] ] ,
31+ 'type-enum' : [ RuleConfigSeverity . Error , 'never' , [ 'foo' ] ] ,
3132 } ) ;
3233 expect ( actual . valid ) . toBe ( false ) ;
3334} ) ;
3435
3536test ( 'positive on ignored message and broken rule' , async ( ) => {
3637 const actual = await lint ( 'Revert "some bogus commit"' , {
37- 'type-empty' : [ 2 , 'never' ] ,
38+ 'type-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
3839 } ) ;
3940 expect ( actual . valid ) . toBe ( true ) ;
4041 expect ( actual . input ) . toBe ( 'Revert "some bogus commit"' ) ;
@@ -44,7 +45,7 @@ test('negative on ignored message, disabled ignored messages and broken rule', a
4445 const actual = await lint (
4546 'Revert "some bogus commit"' ,
4647 {
47- 'type-empty' : [ 2 , 'never' ] ,
48+ 'type-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
4849 } ,
4950 {
5051 defaultIgnores : false ,
@@ -58,7 +59,7 @@ test('positive on custom ignored message and broken rule', async () => {
5859 const actual = await lint (
5960 ignoredMessage ,
6061 {
61- 'type-empty' : [ 2 , 'never' ] ,
62+ 'type-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
6263 } ,
6364 {
6465 ignores : [ ( c ) => c === ignoredMessage ] ,
@@ -72,8 +73,8 @@ test('positive on stub message and opts', async () => {
7273 const actual = await lint (
7374 'foo-bar' ,
7475 {
75- 'type-enum' : [ 2 , 'always' , [ 'foo' ] ] ,
76- 'type-empty' : [ 2 , 'never' ] ,
76+ 'type-enum' : [ RuleConfigSeverity . Error , 'always' , [ 'foo' ] ] ,
77+ 'type-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
7778 } ,
7879 {
7980 parserOpts : {
@@ -85,7 +86,7 @@ test('positive on stub message and opts', async () => {
8586} ) ;
8687
8788test ( 'throws for invalid rule names' , async ( ) => {
88- const error = lint ( 'foo' , { foo : [ 2 , 'always' ] , bar : [ 1 , 'never' ] } ) ;
89+ const error = lint ( 'foo' , { foo : [ RuleConfigSeverity . Error , 'always' ] , bar : [ RuleConfigSeverity . Warning , 'never' ] } ) ;
8990
9091 await expect ( error ) . rejects . toThrow ( / ^ F o u n d i n v a l i d r u l e n a m e s : f o o , b a r / ) ;
9192} ) ;
@@ -150,8 +151,8 @@ test('throws for rule with invalid condition', async () => {
150151
151152test ( 'throws for rule with out of range condition' , async ( ) => {
152153 const error = lint ( 'type(scope): foo' , {
153- 'type-enum' : [ 1 , 'foo' ] as any ,
154- 'header-max-length' : [ 1 , 'bar' ] as any ,
154+ 'type-enum' : [ RuleConfigSeverity . Warning , 'foo' ] as any ,
155+ 'header-max-length' : [ RuleConfigSeverity . Warning , 'bar' ] as any ,
155156 } ) ;
156157
157158 await expect ( error ) . rejects . toThrow ( 'type-enum must be "always" or "never"' ) ;
@@ -162,15 +163,15 @@ test('throws for rule with out of range condition', async () => {
162163
163164test ( 'succeds for issue' , async ( ) => {
164165 const report = await lint ( 'somehting #1' , {
165- 'references-empty' : [ 2 , 'never' ] ,
166+ 'references-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
166167 } ) ;
167168
168169 expect ( report . valid ) . toBe ( true ) ;
169170} ) ;
170171
171172test ( 'fails for issue' , async ( ) => {
172173 const report = await lint ( 'somehting #1' , {
173- 'references-empty' : [ 2 , 'always' ] ,
174+ 'references-empty' : [ RuleConfigSeverity . Error , 'always' ] ,
174175 } ) ;
175176
176177 expect ( report . valid ) . toBe ( false ) ;
@@ -180,7 +181,7 @@ test('succeds for custom issue prefix', async () => {
180181 const report = await lint (
181182 'somehting REF-1' ,
182183 {
183- 'references-empty' : [ 2 , 'never' ] ,
184+ 'references-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
184185 } ,
185186 {
186187 parserOpts : {
@@ -196,7 +197,7 @@ test('fails for custom issue prefix', async () => {
196197 const report = await lint (
197198 'somehting #1' ,
198199 {
199- 'references-empty' : [ 2 , 'never' ] ,
200+ 'references-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
200201 } ,
201202 {
202203 parserOpts : {
@@ -212,7 +213,7 @@ test('fails for custom plugin rule', async () => {
212213 const report = await lint (
213214 'somehting #1' ,
214215 {
215- 'plugin-rule' : [ 2 , 'never' ] ,
216+ 'plugin-rule' : [ RuleConfigSeverity . Error , 'never' ] ,
216217 } ,
217218 {
218219 plugins : {
@@ -232,7 +233,7 @@ test('passes for custom plugin rule', async () => {
232233 const report = await lint (
233234 'somehting #1' ,
234235 {
235- 'plugin-rule' : [ 2 , 'never' ] ,
236+ 'plugin-rule' : [ RuleConfigSeverity . Error , 'never' ] ,
236237 } ,
237238 {
238239 plugins : {
@@ -275,7 +276,7 @@ test('returns original message with commit header, body and footer, parsing comm
275276 const report = await lint (
276277 message ,
277278 {
278- 'references-empty' : [ 2 , 'never' ] ,
279+ 'references-empty' : [ RuleConfigSeverity . Error , 'never' ] ,
279280 } ,
280281 {
281282 parserOpts : {
@@ -291,7 +292,7 @@ test('passes for async rule', async () => {
291292 const report = await lint (
292293 'somehting #1' ,
293294 {
294- 'async-rule' : [ 2 , 'never' ] ,
295+ 'async-rule' : [ RuleConfigSeverity . Error , 'never' ] ,
295296 } ,
296297 {
297298 plugins : {
0 commit comments