@@ -2,21 +2,30 @@ import test from 'ava';
2
2
import m from '..' ;
3
3
4
4
test ( 'Parse GitHub issue' , t => {
5
- t . deepEqual ( m ( 'GitHub' ) ( 'Fix #1 reSOLved gh-2 CLOSES Gh-3 fix o/r#4 #5 o/r#6 fixing #7 Duplicate OF #8 @user' ) , {
6
- actions : [
7
- { raw : 'Fix #1' , action : 'Fix' , slug : undefined , prefix : '#' , issue : '1' } ,
8
- { raw : 'reSOLved gh-2' , action : 'Resolved' , slug : undefined , prefix : 'gh-' , issue : '2' } ,
9
- { raw : 'CLOSES Gh-3' , action : 'Closes' , slug : undefined , prefix : 'Gh-' , issue : '3' } ,
10
- { raw : 'fix o/r#4' , action : 'Fix' , slug : 'o/r' , prefix : '#' , issue : '4' } ,
11
- ] ,
12
- refs : [
13
- { raw : '#5' , slug : undefined , prefix : '#' , issue : '5' } ,
14
- { raw : 'o/r#6' , slug : 'o/r' , prefix : '#' , issue : '6' } ,
15
- { raw : '#7' , slug : undefined , prefix : '#' , issue : '7' } ,
16
- ] ,
17
- duplicates : [ { raw : 'Duplicate OF #8' , action : 'Duplicate of' , slug : undefined , prefix : '#' , issue : '8' } ] ,
18
- mentions : [ { raw : '@user' , prefix : '@' , user : 'user' } ] ,
19
- } ) ;
5
+ t . deepEqual (
6
+ m ( 'GitHub' ) (
7
+ 'Fix #1 reSOLved gh-2 CLOSES Gh-3 fix o/r#4 #5 o/r#6 fix https://github.com/o/r/issues/7 https://github.com/o/r/issues/8 fix https://github.com/o/r/pull/9 https://github.com/o/r/pull/10 fixing #11 Duplicate OF #12 @user'
8
+ ) ,
9
+ {
10
+ actions : [
11
+ { raw : 'Fix #1' , action : 'Fix' , slug : undefined , prefix : '#' , issue : '1' } ,
12
+ { raw : 'reSOLved gh-2' , action : 'Resolved' , slug : undefined , prefix : 'gh-' , issue : '2' } ,
13
+ { raw : 'CLOSES Gh-3' , action : 'Closes' , slug : undefined , prefix : 'Gh-' , issue : '3' } ,
14
+ { raw : 'fix o/r#4' , action : 'Fix' , slug : 'o/r' , prefix : '#' , issue : '4' } ,
15
+ { raw : 'fix https://github.com/o/r/issues/7' , action : 'Fix' , slug : 'o/r' , prefix : undefined , issue : '7' } ,
16
+ { raw : 'fix https://github.com/o/r/pull/9' , action : 'Fix' , slug : 'o/r' , prefix : undefined , issue : '9' } ,
17
+ ] ,
18
+ refs : [
19
+ { raw : '#5' , slug : undefined , prefix : '#' , issue : '5' } ,
20
+ { raw : 'o/r#6' , slug : 'o/r' , prefix : '#' , issue : '6' } ,
21
+ { raw : 'https://github.com/o/r/issues/8' , slug : 'o/r' , prefix : undefined , issue : '8' } ,
22
+ { raw : 'https://github.com/o/r/pull/10' , slug : 'o/r' , prefix : undefined , issue : '10' } ,
23
+ { raw : '#11' , slug : undefined , prefix : '#' , issue : '11' } ,
24
+ ] ,
25
+ duplicates : [ { raw : 'Duplicate OF #12' , action : 'Duplicate of' , slug : undefined , prefix : '#' , issue : '12' } ] ,
26
+ mentions : [ { raw : '@user' , prefix : '@' , user : 'user' } ] ,
27
+ }
28
+ ) ;
20
29
} ) ;
21
30
22
31
test ( 'Parse Bitbucket issue' , t => {
@@ -39,39 +48,75 @@ test('Parse Bitbucket issue', t => {
39
48
} ) ;
40
49
41
50
test ( 'Parse GitLab issue' , t => {
42
- t . deepEqual ( m ( 'GitLab' ) ( 'Fix #1 reSOLved #2 IMPLEMENT #3 fix g/sg/o/r#4 #5 o/r#6 fixing #7 /duplicate #8 @user' ) , {
43
- actions : [
44
- { raw : 'Fix #1' , action : 'Fix' , slug : undefined , prefix : '#' , issue : '1' } ,
45
- { raw : 'reSOLved #2' , action : 'Resolved' , slug : undefined , prefix : '#' , issue : '2' } ,
46
- { raw : 'IMPLEMENT #3' , action : 'Implement' , slug : undefined , prefix : '#' , issue : '3' } ,
47
- { raw : 'fix g/sg/o/r#4' , action : 'Fix' , slug : 'g/sg/o/r' , prefix : '#' , issue : '4' } ,
48
- { raw : 'fixing #7' , action : 'Fixing' , slug : undefined , prefix : '#' , issue : '7' } ,
49
- ] ,
50
- refs : [ { raw : '#5' , slug : undefined , prefix : '#' , issue : '5' } , { raw : 'o/r#6' , slug : 'o/r' , prefix : '#' , issue : '6' } ] ,
51
- duplicates : [ { raw : '/duplicate #8' , action : '/duplicate' , slug : undefined , prefix : '#' , issue : '8' } ] ,
52
- mentions : [ { raw : '@user' , prefix : '@' , user : 'user' } ] ,
53
- } ) ;
51
+ t . deepEqual (
52
+ m ( 'GitLab' ) (
53
+ 'Fix #1 reSOLved #2 IMPLEMENT #3 fix g/sg/o/r#4 #5 o/r#6 fix https://gitlab.com/o/r/issues/7 https://gitlab.com/o/r/issues/8 fix https://gitlab.com/o/r/merge_requests/9 https://gitlab.com/o/r/merge_requests/10 fixing #11 fixing !12 /duplicate #13 @user'
54
+ ) ,
55
+ {
56
+ actions : [
57
+ { raw : 'Fix #1' , action : 'Fix' , slug : undefined , prefix : '#' , issue : '1' } ,
58
+ { raw : 'reSOLved #2' , action : 'Resolved' , slug : undefined , prefix : '#' , issue : '2' } ,
59
+ { raw : 'IMPLEMENT #3' , action : 'Implement' , slug : undefined , prefix : '#' , issue : '3' } ,
60
+ { raw : 'fix g/sg/o/r#4' , action : 'Fix' , slug : 'g/sg/o/r' , prefix : '#' , issue : '4' } ,
61
+ { raw : 'fix https://gitlab.com/o/r/issues/7' , action : 'Fix' , slug : 'o/r' , prefix : undefined , issue : '7' } ,
62
+ { raw : 'fix https://gitlab.com/o/r/merge_requests/9' , action : 'Fix' , slug : 'o/r' , prefix : undefined , issue : '9' } ,
63
+ { raw : 'fixing #11' , action : 'Fixing' , slug : undefined , prefix : '#' , issue : '11' } ,
64
+ { raw : 'fixing !12' , action : 'Fixing' , slug : undefined , prefix : '!' , issue : '12' } ,
65
+ ] ,
66
+ refs : [
67
+ { raw : '#5' , slug : undefined , prefix : '#' , issue : '5' } ,
68
+ { raw : 'o/r#6' , slug : 'o/r' , prefix : '#' , issue : '6' } ,
69
+ { raw : 'https://gitlab.com/o/r/issues/8' , slug : 'o/r' , prefix : undefined , issue : '8' } ,
70
+ { raw : 'https://gitlab.com/o/r/merge_requests/10' , slug : 'o/r' , prefix : undefined , issue : '10' } ,
71
+ ] ,
72
+ duplicates : [ { raw : '/duplicate #13' , action : '/duplicate' , slug : undefined , prefix : '#' , issue : '13' } ] ,
73
+ mentions : [ { raw : '@user' , prefix : '@' , user : 'user' } ] ,
74
+ }
75
+ ) ;
54
76
} ) ;
55
77
56
78
test ( 'Parse with default options' , t => {
57
- t . deepEqual ( m ( ) ( 'Fix #1 reSOLved gh-2 CLOSES Gh-3 fix o/r#4 #5 o/r#6 implementing #7 Duplicate OF #8 @user' ) , {
58
- actions : [
59
- { raw : 'Fix #1' , action : 'Fix' , slug : undefined , prefix : '#' , issue : '1' } ,
60
- { raw : 'reSOLved gh-2' , action : 'Resolved' , slug : undefined , prefix : 'gh-' , issue : '2' } ,
61
- { raw : 'CLOSES Gh-3' , action : 'Closes' , slug : undefined , prefix : 'Gh-' , issue : '3' } ,
62
- { raw : 'fix o/r#4' , action : 'Fix' , slug : 'o/r' , prefix : '#' , issue : '4' } ,
63
- { raw : 'implementing #7' , action : 'Implementing' , slug : undefined , prefix : '#' , issue : '7' } ,
64
- ] ,
65
- refs : [ { raw : '#5' , slug : undefined , prefix : '#' , issue : '5' } , { raw : 'o/r#6' , slug : 'o/r' , prefix : '#' , issue : '6' } ] ,
66
- duplicates : [ { raw : 'Duplicate OF #8' , action : 'Duplicate of' , slug : undefined , prefix : '#' , issue : '8' } ] ,
67
- mentions : [ { raw : '@user' , prefix : '@' , user : 'user' } ] ,
68
- } ) ;
79
+ t . deepEqual (
80
+ m ( ) (
81
+ 'Fix #1 reSOLved gh-2 CLOSES Gh-3 fix o/r#4 #5 o/r#6 implementing #7 https://github.com/o/r/issues/8 implementing https://github.com/o/r/issues/9 Duplicate OF #10 @user'
82
+ ) ,
83
+ {
84
+ actions : [
85
+ { raw : 'Fix #1' , action : 'Fix' , slug : undefined , prefix : '#' , issue : '1' } ,
86
+ { raw : 'reSOLved gh-2' , action : 'Resolved' , slug : undefined , prefix : 'gh-' , issue : '2' } ,
87
+ { raw : 'CLOSES Gh-3' , action : 'Closes' , slug : undefined , prefix : 'Gh-' , issue : '3' } ,
88
+ { raw : 'fix o/r#4' , action : 'Fix' , slug : 'o/r' , prefix : '#' , issue : '4' } ,
89
+ { raw : 'implementing #7' , action : 'Implementing' , slug : undefined , prefix : '#' , issue : '7' } ,
90
+ {
91
+ raw : 'implementing https://github.com/o/r/issues/9' ,
92
+ action : 'Implementing' ,
93
+ slug : 'o/r' ,
94
+ prefix : undefined ,
95
+ issue : '9' ,
96
+ } ,
97
+ ] ,
98
+ refs : [
99
+ { raw : '#5' , slug : undefined , prefix : '#' , issue : '5' } ,
100
+ { raw : 'o/r#6' , slug : 'o/r' , prefix : '#' , issue : '6' } ,
101
+ { raw : 'https://github.com/o/r/issues/8' , slug : 'o/r' , prefix : undefined , issue : '8' } ,
102
+ ] ,
103
+ duplicates : [ { raw : 'Duplicate OF #10' , action : 'Duplicate of' , slug : undefined , prefix : '#' , issue : '10' } ] ,
104
+ mentions : [ { raw : '@user' , prefix : '@' , user : 'user' } ] ,
105
+ }
106
+ ) ;
69
107
} ) ;
70
108
71
109
test ( 'Parse with custom options' , t => {
72
110
t . deepEqual (
73
- m ( { referenceActions : [ 'fix' ] , duplicateActions : [ ] , mentionsPrefixes : '!' , issuePrefixes : [ '#' ] } ) (
74
- 'Fix #1 reSOLved gh-2 CLOSES Gh-3 fixed o/r#4 #5 o/r#6 fixing #7 Duplicate OF #8 !user @other'
111
+ m ( {
112
+ referenceActions : [ 'fix' ] ,
113
+ duplicateActions : [ ] ,
114
+ mentionsPrefixes : '!' ,
115
+ issuePrefixes : [ '#' ] ,
116
+ hosts : [ 'http://host1.com/' , 'http://host2.com' ] ,
117
+ issueURLSegments : [ 'bugs' ] ,
118
+ } ) (
119
+ 'Fix #1 reSOLved gh-2 CLOSES Gh-3 fixed o/r#4 #5 o/r#6 fixing #7 http://host1.com/o/r/bugs/8 http://host2.com/o/r/bugs/9 Duplicate OF #10 !user @other'
75
120
) ,
76
121
{
77
122
actions : [ { raw : 'Fix #1' , action : 'Fix' , slug : undefined , prefix : '#' , issue : '1' } ] ,
@@ -80,7 +125,9 @@ test('Parse with custom options', t => {
80
125
{ raw : '#5' , slug : undefined , prefix : '#' , issue : '5' } ,
81
126
{ raw : 'o/r#6' , slug : 'o/r' , prefix : '#' , issue : '6' } ,
82
127
{ raw : '#7' , slug : undefined , prefix : '#' , issue : '7' } ,
83
- { raw : '#8' , slug : undefined , prefix : '#' , issue : '8' } ,
128
+ { raw : 'http://host1.com/o/r/bugs/8' , slug : 'o/r' , prefix : undefined , issue : '8' } ,
129
+ { raw : 'http://host2.com/o/r/bugs/9' , slug : 'o/r' , prefix : undefined , issue : '9' } ,
130
+ { raw : '#10' , slug : undefined , prefix : '#' , issue : '10' } ,
84
131
] ,
85
132
duplicates : [ ] ,
86
133
mentions : [ { raw : '!user' , prefix : '!' , user : 'user' } ] ,
0 commit comments