File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 99 "strings"
1010 "testing"
1111
12+ "github.com/sergi/go-diff/diffmatchpatch"
1213 "github.com/stretchr/testify/assert"
1314)
1415
@@ -27,6 +28,23 @@ func TestDiffWithHighlight(t *testing.T) {
2728 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 "
2829 output = diffToHTML (nil , diffs , DiffLineAdd )
2930 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 )
3048}
3149
3250func TestDiffWithHighlightPlaceholder (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments