2024-03-31 19:01:47 +00:00
|
|
|
package markdown_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"git.akyoto.dev/go/assert"
|
|
|
|
"git.akyoto.dev/go/markdown"
|
|
|
|
)
|
|
|
|
|
2024-03-31 21:08:01 +00:00
|
|
|
func TestEmpty(t *testing.T) {
|
|
|
|
assert.Equal(t, markdown.Render(""), "")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestParagraphs(t *testing.T) {
|
|
|
|
assert.Equal(t, markdown.Render("Text"), "<p>Text</p>")
|
|
|
|
assert.Equal(t, markdown.Render("Text\n"), "<p>Text</p>")
|
|
|
|
assert.Equal(t, markdown.Render("Text\n\n"), "<p>Text</p>")
|
|
|
|
assert.Equal(t, markdown.Render("Text\n\n\n"), "<p>Text</p>")
|
|
|
|
assert.Equal(t, markdown.Render("Line 1\nLine 2"), "<p>Line 1 Line 2</p>")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHeader(t *testing.T) {
|
|
|
|
assert.Equal(t, markdown.Render("# Header"), "<h1>Header</h1>")
|
|
|
|
assert.Equal(t, markdown.Render("## Header"), "<h2>Header</h2>")
|
|
|
|
assert.Equal(t, markdown.Render("### Header"), "<h3>Header</h3>")
|
|
|
|
assert.Equal(t, markdown.Render("#### Header"), "<h4>Header</h4>")
|
|
|
|
assert.Equal(t, markdown.Render("##### Header"), "<h5>Header</h5>")
|
|
|
|
assert.Equal(t, markdown.Render("###### Header"), "<h6>Header</h6>")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCombined(t *testing.T) {
|
|
|
|
assert.Equal(t, markdown.Render("# Header\nLine 1.\nLine 2.\nLine 3."), "<h1>Header</h1><p>Line 1. Line 2. Line 3.</p>")
|
|
|
|
assert.Equal(t, markdown.Render("# Header 1\nLine 1.\n# Header 2\nLine 2."), "<h1>Header 1</h1><p>Line 1.</p><h1>Header 2</h1><p>Line 2.</p>")
|
2024-03-31 19:01:47 +00:00
|
|
|
}
|