You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
855 B
52 lines
855 B
1 year ago
|
package gmi
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"strconv"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestGemtextToMarkdown(t *testing.T) {
|
||
|
|
||
|
tests := []struct {
|
||
|
in, exp string
|
||
|
}{
|
||
|
{
|
||
|
in: "",
|
||
|
exp: "",
|
||
|
},
|
||
|
{
|
||
|
in: "=> foo",
|
||
|
exp: "[Link](foo)\n",
|
||
|
},
|
||
|
{
|
||
|
in: "what\n=> foo\n=> bar",
|
||
|
exp: "what\n[Link](foo)\n[Link](bar)\n",
|
||
|
},
|
||
|
{
|
||
|
in: "=> foo description is here ",
|
||
|
exp: "[description is here](foo)\n",
|
||
|
},
|
||
|
{
|
||
|
in: "=> img.png",
|
||
|
exp: "![Image](img.png)\n",
|
||
|
},
|
||
|
{
|
||
|
in: "=> img.png description is here ",
|
||
|
exp: "![description is here](img.png)\n",
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for i, test := range tests {
|
||
|
t.Run(strconv.Itoa(i), func(t *testing.T) {
|
||
|
|
||
|
got := new(bytes.Buffer)
|
||
|
err := GemtextToMarkdown(got, bytes.NewBufferString(test.in))
|
||
|
assert.NoError(t, err)
|
||
|
assert.Equal(t, test.exp, got.String())
|
||
|
})
|
||
|
}
|
||
|
}
|