about summary refs log tree commit diff stats
path: root/el/simple_test.go
blob: 2621982dbd8ac2e6ef54021968fddb9a6081fabb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package el_test

import (
	"fmt"
	"testing"

	g "github.com/maragudk/gomponents"
	"github.com/maragudk/gomponents/assert"
	"github.com/maragudk/gomponents/el"
)

func TestSimpleElements(t *testing.T) {
	cases := map[string]func(...g.Node) g.NodeFunc{
		"address":    el.Address,
		"article":    el.Article,
		"aside":      el.Aside,
		"audio":      el.Audio,
		"blockquote": el.BlockQuote,
		"body":       el.Body,
		"button":     el.Button,
		"canvas":     el.Canvas,
		"cite":       el.Cite,
		"code":       el.Code,
		"colgroup":   el.ColGroup,
		"data":       el.Data,
		"datalist":   el.DataList,
		"details":    el.Details,
		"dialog":     el.Dialog,
		"div":        el.Div,
		"dl":         el.Dl,
		"fieldset":   el.FieldSet,
		"figure":     el.Figure,
		"footer":     el.Footer,
		"head":       el.Head,
		"header":     el.Header,
		"hgroup":     el.HGroup,
		"html":       el.HTML,
		"iframe":     el.IFrame,
		"legend":     el.Legend,
		"li":         el.Li,
		"main":       el.Main,
		"menu":       el.Menu,
		"meter":      el.Meter,
		"nav":        el.Nav,
		"noscript":   el.NoScript,
		"object":     el.Object,
		"ol":         el.Ol,
		"optgroup":   el.OptGroup,
		"p":          el.P,
		"picture":    el.Picture,
		"pre":        el.Pre,
		"script":     el.Script,
		"section":    el.Section,
		"span":       el.Span,
		"style":      el.Style,
		"summary":    el.Summary,
		"svg":        el.SVG,
		"table":      el.Table,
		"tbody":      el.TBody,
		"td":         el.Td,
		"tfoot":      el.TFoot,
		"th":         el.Th,
		"thead":      el.THead,
		"tr":         el.Tr,
		"ul":         el.Ul,
	}

	for name, fn := range cases {
		t.Run(fmt.Sprintf("should output %v", name), func(t *testing.T) {
			n := fn(g.Attr("id", "hat"))
			assert.Equal(t, fmt.Sprintf(`<%v id="hat"></%v>`, name, name), n)
		})
	}
}

func TestSimpleVoidKindElements(t *testing.T) {
	cases := map[string]func(...g.Node) g.NodeFunc{
		"area":   el.Area,
		"base":   el.Base,
		"br":     el.Br,
		"col":    el.Col,
		"embed":  el.Embed,
		"hr":     el.Hr,
		"link":   el.Link,
		"meta":   el.Meta,
		"param":  el.Param,
		"source": el.Source,
		"wbr":    el.Wbr,
	}

	for name, fn := range cases {
		t.Run(fmt.Sprintf("should output %v", name), func(t *testing.T) {
			n := fn(g.Attr("id", "hat"))
			assert.Equal(t, fmt.Sprintf(`<%v id="hat">`, name), n)
		})
	}
}