diff options
Diffstat (limited to 'html/attributes_test.go')
-rw-r--r-- | html/attributes_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/html/attributes_test.go b/html/attributes_test.go index 67b98f4..cfb64b5 100644 --- a/html/attributes_test.go +++ b/html/attributes_test.go @@ -78,6 +78,8 @@ func TestSimpleAttributes(t *testing.T) { {Name: "name", Func: Name}, {Name: "pattern", Func: Pattern}, {Name: "placeholder", Func: Placeholder}, + {Name: "popovertarget", Func: PopoverTarget}, + {Name: "popovertargetaction", Func: PopoverTargetAction}, {Name: "poster", Func: Poster}, {Name: "preload", Func: Preload}, {Name: "rel", Func: Rel}, @@ -107,6 +109,37 @@ func TestSimpleAttributes(t *testing.T) { } } +func TestVariadicAttributes(t *testing.T) { + tests := []struct { + Name string + Func func(...string) g.Node + }{ + {Name: "popover", Func: Popover}, + } + + for _, test := range tests { + t.Run(test.Name + "(no args)", func(t *testing.T) { + n := g.El("div", test.Func()) + assert.Equal(t, fmt.Sprintf(`<div %v></div>`, test.Name), n) + }) + + t.Run(test.Name +"(one arg)", func(t *testing.T) { + n := g.El("div", test.Func("hat")) + assert.Equal(t, fmt.Sprintf(`<div %v="hat"></div>`, test.Name), n) + }) + + t.Run(test.Name + "(two args panics)", func(t *testing.T) { + defer func() { + if r := recover(); r == nil { + t.Errorf("expected a panic") + } + }() + n := g.El("div", test.Func("hat", "party")) + assert.Equal(t, "unreachable", n) + }) + } +} + func TestAria(t *testing.T) { t.Run("returns an attribute which name is prefixed with aria-", func(t *testing.T) { n := Aria("selected", "true") |