func TestTransformAttrib(t *testing.T) { node := h5.Anchor("", "") ModifyAttrib("id", "foo")(node) assertEqual(t, node.Attr[0].Val, "foo") TransformAttrib("id", func(s string) string { return "bar" })(node) assertEqual(t, node.Attr[0].Val, "bar") }
func TestAppendChildren(t *testing.T) { node := h5.Anchor("", "") child := h5.Text("foo ") child2 := h5.Text("bar") AppendChildren(child, child2)(node) assertEqual(t, h5.NewTree(node).String(), "<a>foo bar</a>") }
func TestReplaceChildren(t *testing.T) { node := h5.Anchor("", "foo") assertEqual(t, h5.NewTree(node).String(), "<a>foo</a>") child := h5.Text("baz ") child2 := h5.Text("quux") ReplaceChildren(child, child2)(node) assertEqual(t, h5.NewTree(node).String(), "<a>baz quux</a>") }
func TestModifyAttrib(t *testing.T) { node := h5.Anchor("", "") ModifyAttrib("id", "bar")(node) assertEqual(t, node.Attr[0].Val, "bar") ModifyAttrib("class", "baz")(node) assertEqual(t, node.Attr[1].Key, "class") assertEqual(t, node.Attr[1].Val, "baz") }
func TestRemoveChildren(t *testing.T) { node := h5.Anchor("", "foo") RemoveChildren()(node) assertEqual(t, h5.NewTree(node).String(), "<a></a>") }