diff options
Diffstat (limited to 'gomponents_test.go')
-rw-r--r-- | gomponents_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gomponents_test.go b/gomponents_test.go index 3028723..0c5dc68 100644 --- a/gomponents_test.go +++ b/gomponents_test.go @@ -183,3 +183,16 @@ func TestGroup(t *testing.T) { } }) } + +func TestMap(t *testing.T) { + t.Run("maps slices to nodes", func(t *testing.T) { + items := []string{"hat", "partyhat", "turtlehat"} + lis := g.Map(len(items), func(i int) g.Node { + return g.El("li", g.Text(items[i])) + }) + + list := g.El("ul", lis...) + + assert.Equal(t, `<ul><li>hat</li><li>partyhat</li><li>turtlehat</li></ul>`, list) + }) +} |