changeloguru/internal/markdown/node_test.go

63 lines
901 B
Go
Raw Normal View History

2020-11-27 09:50:32 +00:00
package markdown
import (
"testing"
2020-11-27 09:53:52 +00:00
"github.com/stretchr/testify/assert"
2020-11-27 09:50:32 +00:00
)
2020-11-27 11:02:33 +00:00
func TestHeaderString(t *testing.T) {
2020-11-27 09:50:32 +00:00
tests := []struct {
name string
header header
want string
}{
{
name: "level 1",
header: header{
level: 1,
text: "abc",
},
want: "# abc",
},
{
name: "level 3",
header: header{
level: 3,
text: "xyz",
},
want: "### xyz",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
2020-11-27 11:02:33 +00:00
got := tc.header.String()
2020-11-27 09:53:52 +00:00
assert.Equal(t, tc.want, got)
2020-11-27 09:50:32 +00:00
})
}
}
2020-11-27 11:02:33 +00:00
func TestListItemString(t *testing.T) {
2020-11-27 09:50:32 +00:00
tests := []struct {
name string
listItem listItem
want string
}{
{
name: "normal",
listItem: listItem{
text: "abc",
},
want: "- abc",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
2020-11-27 11:02:33 +00:00
got := tc.listItem.String()
2020-11-27 09:53:52 +00:00
assert.Equal(t, tc.want, got)
2020-11-27 09:50:32 +00:00
})
}
}