package site_test import ( "testing" "code.ewintr.nl/go-kit/test" "code.ewintr.nl/shitty-ssg/cmd/ssg/site" "code.ewintr.nl/shitty-ssg/pkg/adoc" ) func TestFormatBlock(t *testing.T) { for _, tc := range []struct { name string element adoc.BlockElement exp string }{ { name: "paragraph", element: adoc.Paragraph{ adoc.PlainText("one"), adoc.PlainText("two"), adoc.PlainText("three"), }, exp: "

onetwothree

", }, { name: "subtitle", element: adoc.SubTitle("text"), exp: `

text

`, }, { name: "subsubtitle", element: adoc.SubSubTitle("text"), exp: "

text

", }, { name: "code", element: adoc.CodeBlock("text"), exp: "
text
", }, { name: "list", element: adoc.List{ {adoc.PlainText("one")}, {adoc.PlainText("two")}, {adoc.PlainText("three")}, }, exp: "", }, } { t.Run(tc.name, func(t *testing.T) { test.Equals(t, tc.exp, site.FormatBlock(tc.element)) }) } } func TestFormatInline(t *testing.T) { for _, tc := range []struct { name string element adoc.InlineElement exp string }{ { name: "plain text", element: adoc.PlainText("text"), exp: "text", }, { name: "strong", element: adoc.StrongText("text"), exp: "text", }, { name: "emphasis", element: adoc.EmpText("text"), exp: "text", }, { name: "strong emphasis", element: adoc.StrongEmpText("text"), exp: "text", }, { name: "link", element: adoc.NewLink("url", "title"), exp: `title`, }, { name: "code", element: adoc.CodeText("text"), exp: "text", }, } { t.Run(tc.name, func(t *testing.T) { test.Equals(t, tc.exp, site.FormatInline(tc.element)) }) } }