-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhtml_test.go
129 lines (103 loc) · 2.67 KB
/
html_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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package htmx
import (
"fmt"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestElementA(t *testing.T) {
t.Parallel()
e := Element("a")
assert.NotNil(t, e)
assert.Implements(t, (*fmt.Stringer)(nil), e)
assert.Equal(t, ElementType, e.Type())
assert.Equal(t, "<a></a>", e.String())
}
func TestElementDiv(t *testing.T) {
t.Parallel()
e := Element("div")
assert.NotNil(t, e)
assert.Implements(t, (*fmt.Stringer)(nil), e)
assert.Equal(t, ElementType, e.Type())
assert.Equal(t, "<div></div>", e.String())
}
func TestElementSpan(t *testing.T) {
t.Parallel()
e := Element("span")
assert.NotNil(t, e)
assert.Implements(t, (*fmt.Stringer)(nil), e)
assert.Equal(t, ElementType, e.Type())
assert.Equal(t, "<span></span>", e.String())
}
func TestElementP(t *testing.T) {
t.Parallel()
e := Element("p")
assert.NotNil(t, e)
assert.Implements(t, (*fmt.Stringer)(nil), e)
assert.Equal(t, ElementType, e.Type())
assert.Equal(t, "<p></p>", e.String())
}
func TestElementH1(t *testing.T) {
t.Parallel()
e := Element("h1")
assert.NotNil(t, e)
assert.Implements(t, (*fmt.Stringer)(nil), e)
assert.Equal(t, ElementType, e.Type())
assert.Equal(t, "<h1></h1>", e.String())
}
func TestElementH2(t *testing.T) {
t.Parallel()
e := Element("h2")
assert.NotNil(t, e)
assert.Implements(t, (*fmt.Stringer)(nil), e)
assert.Equal(t, ElementType, e.Type())
assert.Equal(t, "<h2></h2>", e.String())
}
func TestElementH3(t *testing.T) {
t.Parallel()
e := Element("h3")
assert.NotNil(t, e)
assert.Implements(t, (*fmt.Stringer)(nil), e)
assert.Equal(t, ElementType, e.Type())
assert.Equal(t, "<h3></h3>", e.String())
}
func TestElementH4(t *testing.T) {
t.Parallel()
e := Element("h4")
assert.NotNil(t, e)
assert.Implements(t, (*fmt.Stringer)(nil), e)
assert.Equal(t, ElementType, e.Type())
assert.Equal(t, "<h4></h4>", e.String())
}
func TestElementH5(t *testing.T) {
t.Parallel()
e := Element("h5")
assert.NotNil(t, e)
assert.Implements(t, (*fmt.Stringer)(nil), e)
assert.Equal(t, ElementType, e.Type())
assert.Equal(t, "<h5></h5>", e.String())
}
func TestElementH6(t *testing.T) {
t.Parallel()
e := Element("h6")
assert.NotNil(t, e)
assert.Implements(t, (*fmt.Stringer)(nil), e)
assert.Equal(t, ElementType, e.Type())
assert.Equal(t, "<h6></h6>", e.String())
}
func TestElementCustom(t *testing.T) {
t.Parallel()
e := Element("custom")
assert.NotNil(t, e)
assert.Implements(t, (*fmt.Stringer)(nil), e)
assert.Equal(t, ElementType, e.Type())
assert.Equal(t, "<custom></custom>", e.String())
}
func ExampleElement_a() {
_ = Element("a").Render(os.Stdout)
// Output: <a></a>
}
func ExampleElement_div() {
_ = Element("div").Render(os.Stdout)
// Output: <div></div>
}