From 8de5a685efbc6f13e606dcd70d15b757e3f9ad9a Mon Sep 17 00:00:00 2001
From: Markus Wüstenberg
Date: Mon, 21 Sep 2020 11:23:47 +0200
Subject: Add a lot of common elements (#10)
Especially add elements that are either used in every document, that nearly always have text content, or that are almost always used with certain attributes.---
el/elements_test.go | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 126 insertions(+)
(limited to 'el/elements_test.go')
diff --git a/el/elements_test.go b/el/elements_test.go
index eb0db47..0eee5f3 100644
--- a/el/elements_test.go
+++ b/el/elements_test.go
@@ -37,3 +37,129 @@ func TestTitle(t *testing.T) {
assert.Equal(t, "
hat ", el.Title("hat"))
})
}
+
+func TestMeta(t *testing.T) {
+ t.Run("returns a meta element", func(t *testing.T) {
+ assert.Equal(t, ` `, el.Meta(g.Attr("charset", "utf-8")))
+ })
+}
+
+func TestLink(t *testing.T) {
+ t.Run("returns a link element", func(t *testing.T) {
+ assert.Equal(t, ` `, el.Link(g.Attr("rel", "stylesheet")))
+ })
+}
+
+func TestStyle(t *testing.T) {
+ t.Run("returns a style element", func(t *testing.T) {
+ assert.Equal(t, ``, el.Style(g.Attr("type", "text/css")))
+ })
+}
+
+func TestDiv(t *testing.T) {
+ t.Run("returns a div element", func(t *testing.T) {
+ assert.Equal(t, `
`, el.Div(el.Span()))
+ })
+}
+
+func TestSpan(t *testing.T) {
+ t.Run("returns a span element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.Span(g.Text("hat")))
+ })
+}
+
+func TestA(t *testing.T) {
+ t.Run("returns an a element with a href attribute", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.A("#", g.Text("hat")))
+ })
+}
+
+func TestP(t *testing.T) {
+ t.Run("returns a p element", func(t *testing.T) {
+ assert.Equal(t, `hat
`, el.P(g.Text("hat")))
+ })
+}
+
+func TestH1(t *testing.T) {
+ t.Run("returns an h1 element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.H1("hat"))
+ })
+}
+
+func TestH2(t *testing.T) {
+ t.Run("returns an h2 element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.H2("hat"))
+ })
+}
+
+func TestH3(t *testing.T) {
+ t.Run("returns an h3 element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.H3("hat"))
+ })
+}
+
+func TestH4(t *testing.T) {
+ t.Run("returns an h4 element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.H4("hat"))
+ })
+}
+
+func TestH5(t *testing.T) {
+ t.Run("returns an h5 element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.H5("hat"))
+ })
+}
+
+func TestH6(t *testing.T) {
+ t.Run("returns an h6 element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.H6("hat"))
+ })
+}
+
+func TestOl(t *testing.T) {
+ t.Run("returns an ol element", func(t *testing.T) {
+ assert.Equal(t, ` `, el.Ol(el.Li()))
+ })
+}
+
+func TestUl(t *testing.T) {
+ t.Run("returns a ul element", func(t *testing.T) {
+ assert.Equal(t, ``, el.Ul(el.Li()))
+ })
+}
+
+func TestLi(t *testing.T) {
+ t.Run("returns an li element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.Li(g.Text("hat")))
+ })
+}
+
+func TestB(t *testing.T) {
+ t.Run("returns a b element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.B("hat"))
+ })
+}
+
+func TestStrong(t *testing.T) {
+ t.Run("returns a strong element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.Strong("hat"))
+ })
+}
+
+func TestI(t *testing.T) {
+ t.Run("returns an i element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.I("hat"))
+ })
+}
+
+func TestEm(t *testing.T) {
+ t.Run("returns an em element", func(t *testing.T) {
+ assert.Equal(t, `hat `, el.Em("hat"))
+ })
+}
+
+func TestImg(t *testing.T) {
+ t.Run("returns an img element with href and alt attributes", func(t *testing.T) {
+ assert.Equal(t, ` `, el.Img("hat.png", "hat"))
+ })
+}
--
cgit 1.4.1