1
1
import test from 'ava' ;
2
2
import isIgnored from './is-ignored' ;
3
3
4
+ const VERSION_MESSAGES = [
5
+ '0.0.1' ,
6
+ '0.1.0' ,
7
+ '1.0.0' ,
8
+ '0.0.1-alpha' ,
9
+ '0.0.1-some-crazy-tag' ,
10
+ '0.0.1-0' ,
11
+ '0.0.1-999' ,
12
+ '0.0.1-alpha.0' ,
13
+ '0.0.1-alpha.999' ,
14
+ '0.0.1-some-crazy-tag.0' ,
15
+ '0.0.1-some-crazy-tag.999' ,
16
+ '0.0.1-1e69d54' ,
17
+ 'v0.0.1' ,
18
+ ' v3.0.0'
19
+ ] ;
20
+
21
+ const AMENDMENTS = [
22
+ 'Signed-off-by: Developer <[email protected] >' ,
23
+ 'Change-Id: I895114872a515a269487a683124b63303818e19c' ,
24
+ 'Signed-off-by: Developer <[email protected] >\nChange-Id: I895114872a515a269487a683124b63303818e19c'
25
+ ] ;
26
+
27
+ const AMENDED_VERSION_MESSAGES = VERSION_MESSAGES . reduce ( ( results , message ) => {
28
+ return [
29
+ ...results ,
30
+ ...AMENDMENTS . map ( amendment => `${ message } \n\n${ amendment } ` )
31
+ ] ;
32
+ } , [ ] ) ;
33
+
4
34
test ( 'should return false when called without arguments' , t => {
5
35
t . false ( isIgnored ( ) ) ;
6
36
} ) ;
@@ -13,7 +43,7 @@ test('should return false for normal commit', t => {
13
43
t . false ( isIgnored ( 'initial commit' ) ) ;
14
44
} ) ;
15
45
16
- test ( 'should return false for branch merges' , t => {
46
+ test ( 'should return true for branch merges' , t => {
17
47
t . true ( isIgnored ( "Merge branch 'iss53'" ) ) ;
18
48
} ) ;
19
49
@@ -34,38 +64,13 @@ test('should return true for revert commits', t => {
34
64
) ;
35
65
} ) ;
36
66
37
- const versionCommitInputs = [
38
- '0.0.1' ,
39
- '0.1.0' ,
40
- '1.0.0' ,
41
- '0.0.1-alpha' ,
42
- '0.0.1-some-crazy-tag' ,
43
- '0.0.1-0' ,
44
- '0.0.1-999' ,
45
- '0.0.1-alpha.0' ,
46
- '0.0.1-alpha.999' ,
47
- '0.0.1-some-crazy-tag.0' ,
48
- '0.0.1-some-crazy-tag.999' ,
49
- '0.0.1-1e69d54' ,
50
- 'v0.0.1' ,
51
- ' v3.0.0'
52
- ] ;
53
- for ( let i = 0 , len = versionCommitInputs . length ; i < len ; i ++ ) {
54
- const input = versionCommitInputs [ i ] ;
55
- const commitMsg1 = input ;
56
- const commitMsg2 = `${ input } \n\nSigned-off-by: Developer <[email protected] >` ;
57
- const commitMsg3 = `${ input } \n\nChange-Id: I895114872a515a269487a683124b63303818e19c` ;
58
- const commitMsg4 = `${ input } \n\nSigned-off-by: Developer <[email protected] >\nChange-Id: I895114872a515a269487a683124b63303818e19c` ;
59
-
60
- console . log ( commitMsg1 , commitMsg2 , commitMsg3 , commitMsg4 ) ;
67
+ test ( 'should ignore npm semver commits' , t => {
68
+ VERSION_MESSAGES . forEach ( message => t . true ( isIgnored ( message ) ) ) ;
69
+ } ) ;
61
70
62
- test ( `should return true for version commit permutations of '${ input } '` , t => {
63
- t . true ( isIgnored ( commitMsg1 ) ) ;
64
- t . true ( isIgnored ( commitMsg2 ) ) ;
65
- t . true ( isIgnored ( commitMsg3 ) ) ;
66
- t . true ( isIgnored ( commitMsg4 ) ) ;
67
- } ) ;
68
- }
71
+ test ( 'should ignore npm semver commits with footers' , t => {
72
+ AMENDED_VERSION_MESSAGES . forEach ( message => t . true ( isIgnored ( message ) ) ) ;
73
+ } ) ;
69
74
70
75
test ( 'should return true fixup commits' , t => {
71
76
t . true ( isIgnored ( 'fixup! initial commit' ) ) ;
0 commit comments