@@ -46,15 +46,21 @@ test('Return undefined if there is no match', t => {
46
46
} ) ;
47
47
48
48
test ( 'Match with regex' , t => {
49
- const commit = { type : 'docs' , scope : 'README' } ;
49
+ const rules = [ { type : 'docs' , scope : / t e s t \( .* \) / , release : 'minor' } ] ;
50
+ const match = { type : 'docs' , scope : 'test(readme): message' } ;
51
+ const notMatch = { type : 'docs' , scope : 'test2(readme): message' } ;
50
52
51
- t . is ( analyzeCommit ( [ { type : 'docs' , scope : / R E ..M E / , release : 'minor' } ] , commit ) , 'minor' ) ;
53
+ t . is ( analyzeCommit ( rules , match ) , 'minor' ) ;
54
+ t . is ( analyzeCommit ( rules , notMatch ) , undefined ) ;
52
55
} ) ;
53
56
54
57
test ( 'Match with regex as string' , t => {
55
- const commit = { type : 'docs' , scope : 'README' } ;
58
+ const rules = [ { type : 'docs' , scope : '/test\\(.*\\)/' , release : 'minor' } ] ;
59
+ const match = { type : 'docs' , scope : 'test(readme): message' } ;
60
+ const notMatch = { type : 'docs' , scope : 'test2(readme): message' } ;
56
61
57
- t . is ( analyzeCommit ( [ { type : 'docs' , scope : '/RE..ME/' , release : 'minor' } ] , commit ) , 'minor' ) ;
62
+ t . is ( analyzeCommit ( rules , match ) , 'minor' ) ;
63
+ t . is ( analyzeCommit ( rules , notMatch ) , undefined ) ;
58
64
} ) ;
59
65
60
66
test ( 'Return highest release type if multiple rules match' , t => {
0 commit comments