aboutsummaryrefslogtreecommitdiffstats
path: root/modules/markup/markdown/markdown_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/markup/markdown/markdown_test.go')
-rw-r--r--modules/markup/markdown/markdown_test.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go
index f2322b2554..8f855f1b13 100644
--- a/modules/markup/markdown/markdown_test.go
+++ b/modules/markup/markdown/markdown_test.go
@@ -13,7 +13,7 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
- . "code.gitea.io/gitea/modules/markup/markdown"
+ "code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
@@ -51,14 +51,14 @@ func TestRender_StandardLinks(t *testing.T) {
setting.AppSubURL = AppSubURL
test := func(input, expected, expectedWiki string) {
- buffer, err := RenderString(&markup.RenderContext{
+ buffer, err := markdown.RenderString(&markup.RenderContext{
Ctx: git.DefaultContext,
URLPrefix: setting.AppSubURL,
}, input)
assert.NoError(t, err)
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(buffer))
- buffer, err = RenderString(&markup.RenderContext{
+ buffer, err = markdown.RenderString(&markup.RenderContext{
Ctx: git.DefaultContext,
URLPrefix: setting.AppSubURL,
IsWiki: true,
@@ -82,7 +82,7 @@ func TestRender_Images(t *testing.T) {
setting.AppSubURL = AppSubURL
test := func(input, expected string) {
- buffer, err := RenderString(&markup.RenderContext{
+ buffer, err := markdown.RenderString(&markup.RenderContext{
Ctx: git.DefaultContext,
URLPrefix: setting.AppSubURL,
}, input)
@@ -289,7 +289,7 @@ func TestTotal_RenderWiki(t *testing.T) {
answers := testAnswers(util.URLJoin(AppSubURL, "wiki/"), util.URLJoin(AppSubURL, "wiki", "raw/"))
for i := 0; i < len(sameCases); i++ {
- line, err := RenderString(&markup.RenderContext{
+ line, err := markdown.RenderString(&markup.RenderContext{
Ctx: git.DefaultContext,
URLPrefix: AppSubURL,
Metas: localMetas,
@@ -313,7 +313,7 @@ func TestTotal_RenderWiki(t *testing.T) {
}
for i := 0; i < len(testCases); i += 2 {
- line, err := RenderString(&markup.RenderContext{
+ line, err := markdown.RenderString(&markup.RenderContext{
Ctx: git.DefaultContext,
URLPrefix: AppSubURL,
IsWiki: true,
@@ -330,7 +330,7 @@ func TestTotal_RenderString(t *testing.T) {
answers := testAnswers(util.URLJoin(AppSubURL, "src", "master/"), util.URLJoin(AppSubURL, "raw", "master/"))
for i := 0; i < len(sameCases); i++ {
- line, err := RenderString(&markup.RenderContext{
+ line, err := markdown.RenderString(&markup.RenderContext{
Ctx: git.DefaultContext,
URLPrefix: util.URLJoin(AppSubURL, "src", "master/"),
Metas: localMetas,
@@ -342,7 +342,7 @@ func TestTotal_RenderString(t *testing.T) {
testCases := []string{}
for i := 0; i < len(testCases); i += 2 {
- line, err := RenderString(&markup.RenderContext{
+ line, err := markdown.RenderString(&markup.RenderContext{
Ctx: git.DefaultContext,
URLPrefix: AppSubURL,
}, testCases[i])
@@ -353,17 +353,17 @@ func TestTotal_RenderString(t *testing.T) {
func TestRender_RenderParagraphs(t *testing.T) {
test := func(t *testing.T, str string, cnt int) {
- res, err := RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, str)
+ res, err := markdown.RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, str)
assert.NoError(t, err)
assert.Equal(t, cnt, strings.Count(res, "<p"), "Rendered result for unix should have %d paragraph(s) but has %d:\n%s\n", cnt, strings.Count(res, "<p"), res)
mac := strings.ReplaceAll(str, "\n", "\r")
- res, err = RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, mac)
+ res, err = markdown.RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, mac)
assert.NoError(t, err)
assert.Equal(t, cnt, strings.Count(res, "<p"), "Rendered result for mac should have %d paragraph(s) but has %d:\n%s\n", cnt, strings.Count(res, "<p"), res)
dos := strings.ReplaceAll(str, "\n", "\r\n")
- res, err = RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, dos)
+ res, err = markdown.RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, dos)
assert.NoError(t, err)
assert.Equal(t, cnt, strings.Count(res, "<p"), "Rendered result for windows should have %d paragraph(s) but has %d:\n%s\n", cnt, strings.Count(res, "<p"), res)
}
@@ -391,7 +391,7 @@ func TestMarkdownRenderRaw(t *testing.T) {
for _, testcase := range testcases {
log.Info("Test markdown render error with fuzzy data: %x, the following errors can be recovered", testcase)
- _, err := RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, string(testcase))
+ _, err := markdown.RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, string(testcase))
assert.NoError(t, err)
}
}
@@ -403,7 +403,7 @@ func TestRenderSiblingImages_Issue12925(t *testing.T) {
expected := `<p><a href="/image1" target="_blank" rel="nofollow noopener"><img src="/image1" alt="image1"></a><br>
<a href="/image2" target="_blank" rel="nofollow noopener"><img src="/image2" alt="image2"></a></p>
`
- res, err := RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, testcase)
+ res, err := markdown.RenderRawString(&markup.RenderContext{Ctx: git.DefaultContext}, testcase)
assert.NoError(t, err)
assert.Equal(t, expected, res)
}
@@ -412,7 +412,7 @@ func TestRenderEmojiInLinks_Issue12331(t *testing.T) {
testcase := `[Link with emoji :moon: in text](https://gitea.io)`
expected := `<p><a href="https://gitea.io" rel="nofollow">Link with emoji <span class="emoji" aria-label="waxing gibbous moon">🌔</span> in text</a></p>
`
- res, err := RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, testcase)
+ res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, testcase)
assert.NoError(t, err)
assert.Equal(t, expected, res)
}
@@ -446,7 +446,7 @@ func TestColorPreview(t *testing.T) {
}
for _, test := range positiveTests {
- res, err := RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
+ res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
assert.NoError(t, err, "Unexpected error in testcase: %q", test.testcase)
assert.Equal(t, test.expected, res, "Unexpected result in testcase %q", test.testcase)
@@ -466,7 +466,7 @@ func TestColorPreview(t *testing.T) {
}
for _, test := range negativeTests {
- res, err := RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test)
+ res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test)
assert.NoError(t, err, "Unexpected error in testcase: %q", test)
assert.NotContains(t, res, `<span class="color-preview" style="background-color: `, "Unexpected result in testcase %q", test)
}
@@ -513,7 +513,7 @@ func TestMathBlock(t *testing.T) {
}
for _, test := range testcases {
- res, err := RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
+ res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
assert.NoError(t, err, "Unexpected error in testcase: %q", test.testcase)
assert.Equal(t, test.expected, res, "Unexpected result in testcase %q", test.testcase)
@@ -551,7 +551,7 @@ foo: bar
}
for _, test := range testcases {
- res, err := RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
+ res, err := markdown.RenderString(&markup.RenderContext{Ctx: git.DefaultContext}, test.testcase)
assert.NoError(t, err, "Unexpected error in testcase: %q", test.testcase)
assert.Equal(t, test.expected, res, "Unexpected result in testcase %q", test.testcase)
}