intSel(t, doc.Selection) } func TestRemoveRoot(t *testing.T) { doc := Doc2Clone() doc.Find("html").Remove() assertLength(t, doc.Find("html").Nodes, 0) printSel(t, doc.Selection) } func TestRemoveFiltered(t *testing.T) { doc := Doc2Clone() nf6 := doc.Find("#nf6") s := doc.Find("div").RemoveFiltered("#nf6") assertLength(t, doc.Find("#nf6").Nodes, 0) assertLength(t, s.Nodes, 1) if nf6.Nodes[0] != s.Nodes[0] { t.Error("Removed node does not match original") } printSel(t, doc.Selection) } func TestReplaceWith(t *testing.T) { doc := Doc2Clone() doc.Find("#nf6").ReplaceWith("#main") assertLength(t, doc.Find("#foot #main:last-child").Nodes, 1) printSel(t, doc.Selection) doc.Find("#foot").ReplaceWith("#main") assertLength(t, doc.Find("#foot").Nodes, 0) assertLength(t, doc.Find("#main").Nodes, 1) printSel(t, doc.Selection) } func TestReplaceWithHtml(t *testing.T) { doc := Doc2Clone() doc.Find("#main, #foot").ReplaceWithHtml("
") assertLength(t, doc.Find("#replace").Nodes, 2) printSel(t, doc.Selection) } func TestReplaceWithHtmlContext(t *testing.T) { doc := loadString(t, `| Before1 |
|---|
| Before2 |