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
|
package attr_test
import (
"fmt"
"testing"
g "github.com/maragudk/gomponents"
"github.com/maragudk/gomponents/assert"
"github.com/maragudk/gomponents/attr"
)
func TestSimpleAttributes(t *testing.T) {
cases := map[string]func(string) g.Node{
"accept": attr.Accept,
"autocomplete": attr.AutoComplete,
"charset": attr.Charset,
"class": attr.Class,
"cols": attr.Cols,
"content": attr.Content,
"form": attr.Form,
"height": attr.Height,
"href": attr.Href,
"id": attr.ID,
"lang": attr.Lang,
"max": attr.Max,
"maxlength": attr.MaxLength,
"min": attr.Min,
"minlength": attr.MinLength,
"name": attr.Name,
"pattern": attr.Pattern,
"preload": attr.Preload,
"placeholder": attr.Placeholder,
"rel": attr.Rel,
"rows": attr.Rows,
"src": attr.Src,
"style": attr.Style,
"tabindex": attr.TabIndex,
"target": attr.Target,
"title": attr.Title,
"type": attr.Type,
"value": attr.Value,
"width": attr.Width,
}
for name, fn := range cases {
t.Run(fmt.Sprintf(`should output %v="hat"`, name), func(t *testing.T) {
n := g.El("div", fn("hat"))
assert.Equal(t, fmt.Sprintf(`<div %v="hat"></div>`, name), n)
})
}
}
|