@@ -9,15 +9,17 @@ import (
9
9
"os"
10
10
"testing"
11
11
12
+ "code.gitea.io/gitea/models/issues"
12
13
"code.gitea.io/gitea/models/unittest"
13
14
"code.gitea.io/gitea/modules/git"
14
15
"code.gitea.io/gitea/modules/log"
15
16
"code.gitea.io/gitea/modules/markup"
17
+ "code.gitea.io/gitea/modules/translation"
16
18
17
19
"github.com/stretchr/testify/assert"
18
20
)
19
21
20
- const testInput = ` space @mention-user
22
+ const testInput = ` space @mention-user
21
23
/just/a/path.bin
22
24
https://example.com/file.bin
23
25
[local link](file.bin)
@@ -36,7 +38,7 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
36
38
37
39
@mention-user test
38
40
#123
39
- space
41
+ space
40
42
`
41
43
42
44
var testMetas = map [string ]string {
@@ -137,7 +139,7 @@ func TestRenderCommitMessageLinkSubject(t *testing.T) {
137
139
}
138
140
139
141
func TestRenderIssueTitle (t * testing.T ) {
140
- expected := ` space @mention-user
142
+ expected := ` space @mention-user
141
143
/just/a/path.bin
142
144
https://example.com/file.bin
143
145
[local link](file.bin)
@@ -156,7 +158,7 @@ com 88fc37a3c0a4dda553bdcfc80c178a58247f42fb mit
156
158
157
159
@mention-user test
158
160
<a href="/user13/repo11/issues/123" class="ref-issue">#123</a>
159
- space
161
+ space
160
162
`
161
163
assert .EqualValues (t , expected , RenderIssueTitle (context .Background (), testInput , testMetas ))
162
164
}
@@ -185,3 +187,18 @@ space</p>
185
187
`
186
188
assert .EqualValues (t , expected , RenderMarkdownToHtml (context .Background (), testInput ))
187
189
}
190
+
191
+ func TestRenderLabels (t * testing.T ) {
192
+ ctx := context .Background ()
193
+ locale := & translation.MockLocale {}
194
+
195
+ label := & issues.Label {ID : 123 , Name : "label-name" , Color : "label-color" }
196
+ issue := & issues.Issue {}
197
+ expected := `/owner/repo/issues?labels=123`
198
+ assert .Contains (t , RenderLabels (ctx , locale , []* issues.Label {label }, "/owner/repo" , issue ), expected )
199
+
200
+ label = & issues.Label {ID : 123 , Name : "label-name" , Color : "label-color" }
201
+ issue = & issues.Issue {IsPull : true }
202
+ expected = `/owner/repo/pulls?labels=123`
203
+ assert .Contains (t , RenderLabels (ctx , locale , []* issues.Label {label }, "/owner/repo" , issue ), expected )
204
+ }
0 commit comments