(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func Test_diffsToHTML(t *testing.T) { |
| 14 | tests := []struct { |
| 15 | diffs []dmp.Diff |
| 16 | lineType git.DiffLineType |
| 17 | expHTML template.HTML |
| 18 | }{ |
| 19 | { |
| 20 | diffs: []dmp.Diff{ |
| 21 | {Type: dmp.DiffEqual, Text: "foo "}, |
| 22 | {Type: dmp.DiffInsert, Text: "bar"}, |
| 23 | {Type: dmp.DiffDelete, Text: " baz"}, |
| 24 | {Type: dmp.DiffEqual, Text: " biz"}, |
| 25 | }, |
| 26 | lineType: git.DiffLineAdd, |
| 27 | expHTML: template.HTML(`+foo <span class="added-code">bar</span> biz`), |
| 28 | }, |
| 29 | { |
| 30 | diffs: []dmp.Diff{ |
| 31 | {Type: dmp.DiffEqual, Text: "foo "}, |
| 32 | {Type: dmp.DiffDelete, Text: "bar"}, |
| 33 | {Type: dmp.DiffInsert, Text: " baz"}, |
| 34 | {Type: dmp.DiffEqual, Text: " biz"}, |
| 35 | }, |
| 36 | lineType: git.DiffLineDelete, |
| 37 | expHTML: template.HTML(`-foo <span class="removed-code">bar</span> biz`), |
| 38 | }, |
| 39 | } |
| 40 | for _, test := range tests { |
| 41 | t.Run("", func(t *testing.T) { |
| 42 | assert.Equal(t, test.expHTML, diffsToHTML(test.diffs, test.lineType)) |
| 43 | }) |
| 44 | } |
| 45 | } |
nothing calls this directly
no test coverage detected