1
0
Fork 0
forked from forgejo/forgejo

Improved comment rendering in "Files" view by adding Comments to DiffLine

Signed-off-by: Jonas Franz <info@jonasfranz.software>
This commit is contained in:
Jonas Franz 2018-05-12 19:09:42 +02:00
parent 58fb672d0d
commit 066086c390
No known key found for this signature in database
GPG key ID: 506AEEBE80BEDECD
9 changed files with 112 additions and 26 deletions

View file

@ -5,6 +5,7 @@ import (
"testing"
dmp "github.com/sergi/go-diff/diffmatchpatch"
"github.com/stretchr/testify/assert"
)
func assertEqual(t *testing.T, s1 string, s2 template.HTML) {
@ -34,3 +35,28 @@ func TestDiffToHTML(t *testing.T) {
{Type: dmp.DiffEqual, Text: " biz"},
}, DiffLineDel))
}
func TestDiff_LoadComments(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
issue := AssertExistsAndLoadBean(t, &Issue{ID: 2}).(*Issue)
user := AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)
diff := &Diff{
Files: []*DiffFile{
{
Name: "README.md",
Sections: []*DiffSection{
{
Lines: []*DiffLine{
{
LeftIdx: 4,
RightIdx: 4,
},
},
},
},
},
},
}
assert.NoError(t, diff.LoadComments(issue, user))
assert.Len(t, diff.Files[0].Sections[0].Lines[0].Comments, 2)
}