-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
options_test.go
52 lines (46 loc) · 1001 Bytes
/
options_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
package tags
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_Options_String(t *testing.T) {
r := require.New(t)
o := Options{
"value": "Mark",
"id": "foo-bar",
"class": "foo bar baz",
}
s := o.String()
r.Equal(`class="foo bar baz" id="foo-bar" value="Mark"`, s)
}
func Test_Options_String_Escaped(t *testing.T) {
r := require.New(t)
o := Options{
"<b>": "<p>",
}
s := o.String()
r.Equal(`<b>="<p>"`, s)
}
func Test_Options_String_Empty_Attribute(t *testing.T) {
r := require.New(t)
o := Options{
"value": "Mark",
"checked": nil,
}
s := o.String()
r.Equal(`checked value="Mark"`, s)
}
func Test_Options_Data_Map(t *testing.T) {
r := require.New(t)
o := Options{
"value": "Mark",
"id": "foo-bar",
"class": "foo bar baz",
"data": map[string]interface{}{
"remote": true,
"method": "PUT",
},
}
s := o.String()
r.Equal(`class="foo bar baz" data-method="PUT" data-remote="true" id="foo-bar" value="Mark"`, s)
}