Skip to content

Commit

Permalink
test case for Issue #2212
Browse files Browse the repository at this point in the history
  • Loading branch information
MicyToy authored and jhy committed Nov 25, 2024
1 parent 28db617 commit df404cf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/java/org/jsoup/nodes/NodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.jsoup.select.NodeVisitor;
import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.List;

import static org.jsoup.parser.Parser.*;
Expand Down Expand Up @@ -175,6 +176,22 @@ public void handlesAbsOnProtocolessAbsoluteUris() {
assertEquals("One <em>foo</em> three", p.html());
}

/**
* test case for
* <a href="https://github.com/jhy/jsoup/issues/2212">Issue #2212</a>
*/
@Test public void testReplaceTwice() {
Document doc = Jsoup.parse("<p><span>Child One</span><span>Child Two</span><span>Child Three</span><span>Child Four</span></p>");
Elements children = doc.select("p").first().children();
// first swap 0 and 1
children.set(0, children.set(1, children.get(0)));
// then swap 1 and 2
children.set(2, children.set(1, children.get(2)));

assertEquals("Child TwoChild ThreeChild OneChild Four",
TextUtil.stripNewlines(children.html()));
}

@Test public void ownerDocument() {
Document doc = Jsoup.parse("<p>Hello");
Element p = doc.select("p").first();
Expand Down

0 comments on commit df404cf

Please sign in to comment.