File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 9
9
"strings"
10
10
"testing"
11
11
12
+ "github.com/sergi/go-diff/diffmatchpatch"
12
13
"github.com/stretchr/testify/assert"
13
14
)
14
15
@@ -27,6 +28,23 @@ func TestDiffWithHighlight(t *testing.T) {
27
28
expected = ` <span class="n">run</span><span class="o">(</span><span class="added-code"><span class="n">db</span></span><span class="o">)</span>` + "\n "
28
29
output = diffToHTML (nil , diffs , DiffLineAdd )
29
30
assert .Equal (t , expected , output )
31
+
32
+ hcd = newHighlightCodeDiff ()
33
+ hcd .placeholderTokenMap ['O' ] = "<span>"
34
+ hcd .placeholderTokenMap ['C' ] = "</span>"
35
+ diff := diffmatchpatch.Diff {}
36
+
37
+ diff .Text = "OC"
38
+ hcd .recoverOneDiff (& diff )
39
+ assert .Equal (t , "<span></span>" , diff .Text )
40
+
41
+ diff .Text = "O"
42
+ hcd .recoverOneDiff (& diff )
43
+ assert .Equal (t , "<span></span>" , diff .Text )
44
+
45
+ diff .Text = "C"
46
+ hcd .recoverOneDiff (& diff )
47
+ assert .Equal (t , "" , diff .Text )
30
48
}
31
49
32
50
func TestDiffWithHighlightPlaceholder (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments