1
- import { Level , Rule } from '@commitlint/load' ;
1
+ import type { RuleConfigTuple } from '@commitlint/types' ;
2
+ import { RuleConfigSeverity } from '@commitlint/types' ;
2
3
import { emptyWhen , enumWhen , whenFactory } from './when' ;
3
4
4
5
describe ( 'when' , ( ) => {
@@ -10,25 +11,25 @@ describe('when', () => {
10
11
} ) ;
11
12
12
13
test ( 'should return true if level is disable' , ( ) => {
13
- const result = enumWhen ( [ Level . Disable , 'always' , [ ] ] ) ;
14
+ const result = enumWhen ( [ RuleConfigSeverity . Disabled , 'always' , [ ] ] ) ;
14
15
15
16
expect ( result ) . toBe ( true ) ;
16
17
} ) ;
17
18
18
19
test ( 'should return true if applicable is never' , ( ) => {
19
- const result = enumWhen ( [ Level . Error , 'never' , [ ] ] ) ;
20
+ const result = enumWhen ( [ RuleConfigSeverity . Error , 'never' , [ ] ] ) ;
20
21
21
22
expect ( result ) . toBe ( true ) ;
22
23
} ) ;
23
24
24
25
test ( 'should return true when array not empty' , ( ) => {
25
- const result = enumWhen ( [ Level . Error , 'always' , [ 'foo' ] ] ) ;
26
+ const result = enumWhen ( [ RuleConfigSeverity . Error , 'always' , [ 'foo' ] ] ) ;
26
27
27
28
expect ( result ) . toBe ( true ) ;
28
29
} ) ;
29
30
30
31
test ( 'should return false when array empty' , ( ) => {
31
- const result = enumWhen ( [ Level . Error , 'always' , [ ] ] ) ;
32
+ const result = enumWhen ( [ RuleConfigSeverity . Error , 'always' , [ ] ] ) ;
32
33
33
34
expect ( result ) . toBe ( false ) ;
34
35
} ) ;
@@ -42,29 +43,29 @@ describe('when', () => {
42
43
} ) ;
43
44
44
45
test ( 'should return true if level is disable' , ( ) => {
45
- const result = emptyWhen ( [ Level . Disable , 'always' , undefined ] ) ;
46
+ const result = emptyWhen ( [ RuleConfigSeverity . Disabled , 'always' ] ) ;
46
47
47
48
expect ( result ) . toBe ( true ) ;
48
49
} ) ;
49
50
50
51
test ( 'should return true if applicable is never' , ( ) => {
51
- const result = emptyWhen ( [ Level . Error , 'never' , undefined ] ) ;
52
+ const result = emptyWhen ( [ RuleConfigSeverity . Error , 'never' ] ) ;
52
53
53
54
expect ( result ) . toBe ( true ) ;
54
55
} ) ;
55
56
56
57
test ( 'should return false if applicable is always' , ( ) => {
57
- const result = emptyWhen ( [ Level . Error , 'always' , undefined ] ) ;
58
+ const result = emptyWhen ( [ RuleConfigSeverity . Error , 'always' ] ) ;
58
59
59
60
expect ( result ) . toBe ( false ) ;
60
61
} ) ;
61
62
} ) ;
62
63
63
64
describe ( 'whenFactory' , ( ) => {
64
- const hidePromptEnumRule : Rule < string [ ] > | undefined = [ Level . Error , 'always' , [ ] ] ;
65
- const hidePromptEmptyRule : Rule < undefined > | undefined = [ Level . Error , 'always' , undefined ] ;
65
+ const hidePromptEnumRule : RuleConfigTuple < string [ ] > | undefined = [ RuleConfigSeverity . Error , 'always' , [ ] ] ;
66
+ const hidePromptEmptyRule : RuleConfigTuple < undefined > | undefined = [ RuleConfigSeverity . Error , 'always' ] ;
66
67
67
- test . each < [ Rule < string [ ] > | undefined , Rule < undefined > | undefined , boolean ] > ( [
68
+ test . each < [ RuleConfigTuple < string [ ] > | undefined , RuleConfigTuple < undefined > | undefined , boolean ] > ( [
68
69
[ undefined , undefined , true ] ,
69
70
[ undefined , hidePromptEmptyRule , false ] ,
70
71
[ hidePromptEnumRule , undefined , false ] ,
0 commit comments