예제 #1
0
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")
}
예제 #2
0
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>")
}
예제 #3
0
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>")
}
예제 #4
0
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")
}
예제 #5
0
func TestRemoveChildren(t *testing.T) {
	node := h5.Anchor("", "foo")
	RemoveChildren()(node)
	assertEqual(t, h5.NewTree(node).String(), "<a></a>")
}