1
1
import * as plugin from '../src' ;
2
- import { Plugin , RuleOutcome , RulesConfig } from '@commitlint/types' ;
2
+ import { Plugin , QualifiedRules , RuleOutcome } from '@commitlint/types' ;
3
3
import { describe , expect , it } from '@jest/globals' ;
4
4
import lint from '@commitlint/lint' ;
5
5
import load from '@commitlint/load' ;
6
6
7
7
describe ( 'commitlint plugin function rules' , ( ) => {
8
+ it ( 'can be loaded using @commitlint/load' , async ( ) => {
9
+ await expect (
10
+ load ( {
11
+ plugins : [ plugin as Plugin ] ,
12
+ } ) ,
13
+ ) . resolves . not . toThrow ( ) ;
14
+ } ) ;
15
+
8
16
it ( 'provides rules that can be used with commitlint' , async ( ) => {
9
17
for await ( const rule of Object . keys ( plugin . rules ) ) {
10
18
const results : RuleOutcome [ ] = [
11
19
[ true ] ,
12
20
[ false , `error message from ${ rule } ` ] ,
13
21
] ;
22
+
14
23
for await ( const result of results ) {
15
- const rules : Partial < RulesConfig > = { } ;
24
+ const rules : Partial < QualifiedRules > = { } ;
16
25
rules [ rule ] = [
17
26
2 ,
18
27
'always' ,
@@ -21,12 +30,7 @@ describe('commitlint plugin function rules', () => {
21
30
} ,
22
31
] ;
23
32
24
- const config = await load ( {
25
- plugins : [ plugin as Plugin ] ,
26
- rules,
27
- } ) ;
28
-
29
- const report = await lint ( 'chore: basic commit message' , config . rules , {
33
+ const report = await lint ( 'chore: basic commit message' , rules , {
30
34
plugins : {
31
35
'function-rules' : plugin as Plugin ,
32
36
} ,
0 commit comments