From 69b0da41dff1813f3939cf4ea09fbbb2d06b7719 Mon Sep 17 00:00:00 2001 From: Markus Wüstenberg Date: Thu, 19 Sep 2024 19:33:58 +0200 Subject: Drop support for Go 1.16 and Go 1.17 (#203) Fixes #184--- gomponents_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'gomponents_test.go') diff --git a/gomponents_test.go b/gomponents_test.go index f3e81b0..27fb534 100644 --- a/gomponents_test.go +++ b/gomponents_test.go @@ -227,6 +227,28 @@ func ExampleRawf() { // Output: > normal hats. } +func TestMap(t *testing.T) { + t.Run("maps slices to nodes", func(t *testing.T) { + items := []string{"hat", "partyhat", "turtlehat"} + lis := g.Map(items, func(i string) g.Node { + return g.El("li", g.Text(i)) + }) + + list := g.El("ul", lis...) + + assert.Equal(t, ``, list) + }) +} + +func ExampleMap() { + items := []string{"party hat", "super hat"} + e := g.El("ul", g.Group(g.Map(items, func(i string) g.Node { + return g.El("li", g.Text(i)) + }))) + _ = e.Render(os.Stdout) + // Output: +} + func TestGroup(t *testing.T) { t.Run("groups multiple nodes into one", func(t *testing.T) { children := []g.Node{g.El("br", g.Attr("id", "hat")), g.El("hr")} -- cgit 1.4.1