code.gitea.io/gitea@v1.19.3/modules/markup/csv/csv_test.go (about) 1 // Copyright 2018 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package markup 5 6 import ( 7 "strings" 8 "testing" 9 10 "code.gitea.io/gitea/modules/git" 11 "code.gitea.io/gitea/modules/markup" 12 13 "github.com/stretchr/testify/assert" 14 ) 15 16 func TestRenderCSV(t *testing.T) { 17 var render Renderer 18 kases := map[string]string{ 19 "a": "<table class=\"data-table\"><tr><th class=\"line-num\">1</th><th>a</th></tr></table>", 20 "1,2": "<table class=\"data-table\"><tr><th class=\"line-num\">1</th><th>1</th><th>2</th></tr></table>", 21 "1;2\n3;4": "<table class=\"data-table\"><tr><th class=\"line-num\">1</th><th>1</th><th>2</th></tr><tr><td class=\"line-num\">2</td><td>3</td><td>4</td></tr></table>", 22 "<br/>": "<table class=\"data-table\"><tr><th class=\"line-num\">1</th><th><br/></th></tr></table>", 23 } 24 25 for k, v := range kases { 26 var buf strings.Builder 27 err := render.Render(&markup.RenderContext{Ctx: git.DefaultContext}, 28 strings.NewReader(k), &buf) 29 assert.NoError(t, err) 30 assert.EqualValues(t, v, buf.String()) 31 } 32 }