-
Notifications
You must be signed in to change notification settings - Fork 0
/
elements_test.go
59 lines (48 loc) · 1.38 KB
/
elements_test.go
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
package gorgeous
import "testing"
func TestEmpty(t *testing.T) {
output := RenderElement(Empty(), "")
if output.Document.String() != "" {
t.Errorf("Empty() did not render an empty string: %s", output.Document.String())
}
}
func TestTextTableDriven(t *testing.T) {
tests := []struct {
input string
expected string
}{
{"", ""},
{"test", "test"},
{"<test>", "<test>"},
{"<test>test</test>", "<test>test</test>"},
}
for _, test := range tests {
output := RenderElement(Text(test.input), "")
if output.Document.String() != test.expected {
t.Errorf("Text(\"%s\") did not render \"%s\", got: \"%s\"", test.input, test.expected, output.Document.String())
}
}
}
func TestRawTextTableDriven(t *testing.T) {
tests := []struct {
input string
expected string
}{
{"", ""},
{"test", "test"},
{"<test>", "<test>"},
{"<test>test</test>", "<test>test</test>"},
}
for _, test := range tests {
output := RenderElement(RawText(test.input), "")
if output.Document.String() != test.expected {
t.Errorf("RawText(\"%s\") did not render \"%s\", got: \"%s\"", test.input, test.expected, output.Document.String())
}
}
}
func TestBody(t *testing.T) {
output := RenderElement(Body(EB{}), "")
if output.Document.String() != "<body id=\"body\"></body>" {
t.Errorf("Body() did not render \"<body></body>\", got: \"%s\"", output.Document.String())
}
}