2021-05-05 03:53:32 -07:00
|
|
|
package svg_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
g "github.com/maragudk/gomponents"
|
2021-10-06 11:49:43 -07:00
|
|
|
"github.com/maragudk/gomponents/internal/assert"
|
2021-05-05 03:53:32 -07:00
|
|
|
. "github.com/maragudk/gomponents/svg"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSimpleAttributes(t *testing.T) {
|
|
|
|
cases := map[string]func(string) g.Node{
|
2022-11-15 05:48:01 -08:00
|
|
|
"clip-rule": ClipRule,
|
|
|
|
"d": D,
|
|
|
|
"fill": Fill,
|
|
|
|
"fill-rule": FillRule,
|
|
|
|
"stroke": Stroke,
|
|
|
|
"stroke-width": StrokeWidth,
|
|
|
|
"viewBox": ViewBox,
|
2021-05-05 03:53:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for name, fn := range cases {
|
|
|
|
t.Run(fmt.Sprintf(`should output %v="hat"`, name), func(t *testing.T) {
|
|
|
|
n := g.El("element", fn("hat"))
|
|
|
|
assert.Equal(t, fmt.Sprintf(`<element %v="hat"></element>`, name), n)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|