From 13701c4f668eba27956a8ac554a1fe272245d210 Mon Sep 17 00:00:00 2001 From: Markus Wüstenberg Date: Wed, 28 Oct 2020 16:59:04 +0100 Subject: Add attribute helpers (#35) Also refactor tests to be table-driven, for readability.--- attr/boolean_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 attr/boolean_test.go (limited to 'attr/boolean_test.go') diff --git a/attr/boolean_test.go b/attr/boolean_test.go new file mode 100644 index 0000000..4e6bb37 --- /dev/null +++ b/attr/boolean_test.go @@ -0,0 +1,32 @@ +package attr_test + +import ( + "fmt" + "testing" + + g "github.com/maragudk/gomponents" + "github.com/maragudk/gomponents/assert" + "github.com/maragudk/gomponents/attr" +) + +func TestBooleanAttributes(t *testing.T) { + cases := map[string]func() g.Node{ + "async": attr.Async, + "autofocus": attr.AutoFocus, + "autoplay": attr.AutoPlay, + "controls": attr.Controls, + "defer": attr.Defer, + "disabled": attr.Disabled, + "multiple": attr.Multiple, + "readonly": attr.ReadOnly, + "required": attr.Required, + "selected": attr.Selected, + } + + for name, fn := range cases { + t.Run(fmt.Sprintf("should output %v", name), func(t *testing.T) { + n := g.El("div", fn()) + assert.Equal(t, fmt.Sprintf(`
`, name), n) + }) + } +} -- cgit 1.4.1