2022-03-15 15:16:15 +01:00
|
|
|
package element_test
|
2022-03-10 06:10:36 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
2022-06-11 09:30:22 +02:00
|
|
|
"ewintr.nl/adoc/document"
|
2022-03-15 15:16:15 +01:00
|
|
|
"ewintr.nl/adoc/element"
|
|
|
|
"ewintr.nl/adoc/parser"
|
2022-03-10 06:10:36 +01:00
|
|
|
"ewintr.nl/go-kit/test"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSubTitle(t *testing.T) {
|
|
|
|
for _, tc := range []struct {
|
|
|
|
name string
|
|
|
|
input string
|
2022-03-15 15:16:15 +01:00
|
|
|
exp []element.Element
|
2022-03-10 06:10:36 +01:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "empty",
|
|
|
|
input: "== ",
|
2022-03-15 15:16:15 +01:00
|
|
|
exp: []element.Element{element.SubTitle("")},
|
2022-03-10 06:10:36 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "subtitle",
|
|
|
|
input: "== title with words",
|
2022-03-15 15:16:15 +01:00
|
|
|
exp: []element.Element{element.SubTitle("title with words")},
|
2022-03-10 06:10:36 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "subsubtitle",
|
|
|
|
input: "=== title",
|
2022-03-15 15:16:15 +01:00
|
|
|
exp: []element.Element{element.SubSubTitle("title")},
|
2022-03-10 06:10:36 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "trailing newline",
|
|
|
|
input: "== title\n",
|
2022-03-15 15:16:15 +01:00
|
|
|
exp: []element.Element{element.SubTitle("title")},
|
2022-03-10 06:10:36 +01:00
|
|
|
},
|
|
|
|
} {
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
2022-06-11 09:30:22 +02:00
|
|
|
exp := &document.Document{
|
2022-03-10 06:10:36 +01:00
|
|
|
Attributes: map[string]string{},
|
|
|
|
Content: tc.exp,
|
|
|
|
}
|
2022-03-15 15:16:15 +01:00
|
|
|
par := parser.New(strings.NewReader(tc.input))
|
2022-03-10 06:10:36 +01:00
|
|
|
test.Equals(t, exp, par.Parse())
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|