Skip to content

Commit

Permalink
Test for #1998
Browse files Browse the repository at this point in the history
Closes #1998

Was fixed by #2146
  • Loading branch information
jhy committed Aug 27, 2024
1 parent 2bffb65 commit d5debf8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/test/java/org/jsoup/nodes/ElementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;

import static org.jsoup.select.SelectorTest.assertSelectedOwnText;
import static org.junit.jupiter.api.Assertions.*;

/**
Expand Down Expand Up @@ -2636,7 +2637,7 @@ void prettySerializationRoundTrips(Document.OutputSettings settings) {
assertEquals(selected.first(), div);
}

@Test void cssSelectorWithAstrix() {
@Test void cssSelectorWithAsterisk() {
// https://github.com/jhy/jsoup/issues/2169
Document doc = Jsoup.parse("<div class='vds-items_flex-end [&amp;_>_*:first-child]:vds-pt_0'>One</div><div class='vds-items_flex-end'>Two</div>");
Element div = doc.expectFirst("div");
Expand All @@ -2648,6 +2649,16 @@ void prettySerializationRoundTrips(Document.OutputSettings settings) {
assertEquals(selected.first(), div);
}

@Test void cssSelectorWithPipe() {
// https://github.com/jhy/jsoup/issues/1998
Document doc = Jsoup.parse("<div><span class='|'>One</div>");
Element span = doc.expectFirst("div span");
String selector = span.cssSelector();
assertEquals("html > body > div > span.\\|", selector);
Elements selected = doc.select(selector);
assertSelectedOwnText(selected, "One");
}

@Test void orphanSiblings() {
Element el = new Element("div");
assertEquals(0, el.siblingElements().size());
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/jsoup/select/SelectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void assertSelectedIds(Elements els, String... ids) {
}
}

static void assertSelectedOwnText(Elements els, String... ownTexts) {
public static void assertSelectedOwnText(Elements els, String... ownTexts) {
assertNotNull(els);
assertEquals(ownTexts.length, els.size(), "Incorrect number of selected elements");
for (int i = 0; i < ownTexts.length; i++) {
Expand Down

0 comments on commit d5debf8

Please sign in to comment.