Skip to content

Commit 9d64cbe

Browse files
Mertzenichslipset
authored andcommitted
tests: find-in-text in a child selector assertion
1 parent 139484a commit 9d64cbe

File tree

1 file changed

+38
-32
lines changed

1 file changed

+38
-32
lines changed

test/cljc/hickory/test/select.cljc

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,38 @@
88

99
(def html1
1010
"<!DOCTYPE html>
11-
<!-- Comment 1 -->
12-
<html>
13-
<head></head>
14-
<body>
15-
<h1>Heading</h1>
16-
<p>Paragraph</p>
17-
<a href=\"http://example.com\">Link</a>
18-
<div class=\"aclass bclass cool\">
19-
<span disabled anotherattr=\"\" thirdthing=\"44\" id=\"attrspan\"
20-
Capitalized=\"UPPERCASED\">
21-
<div class=\"subdiv cool\" id=\"deepestdiv\">Div</div>
22-
</span>
23-
<!-- Comment 2 -->
24-
<span id=\"anid\" class=\"line-feed-ahead
25-
cool\">Span</span>
26-
</div>
27-
</body>
28-
</html>")
11+
<!-- Comment 1 -->
12+
<html>
13+
<head></head>
14+
<body>
15+
<h1>Heading</h1>
16+
<p>Paragraph</p>
17+
<a href=\"http://example.com\">Link</a>
18+
<div class=\"aclass bclass cool\">
19+
<span disabled anotherattr=\"\" thirdthing=\"44\" id=\"attrspan\" Capitalized=\"UPPERCASED\">
20+
<div class=\"subdiv cool\" id=\"deepestdiv\">Div</div>
21+
</span>
22+
<!-- Comment 2 -->
23+
<span id=\"anid\" class=\"line-feed-ahead cool\">Span</span>
24+
</div>
25+
</body>
26+
</html>")
2927

3028
(def html2
3129
"<!DOCTYPE html>
32-
<html>
33-
<head></head>
34-
<body>
35-
<p>Paragraph 1</p>
36-
<p>Paragraph 2</p>
37-
<p>Paragraph 3</p>
38-
<p>Paragraph 4</p>
39-
<p>Paragraph 5</p>
40-
<p>Paragraph 6</p>
41-
<p>Paragraph 7</p>
42-
<p>Paragraph 8</p>
43-
</body>
44-
</html>")
30+
<html>
31+
<head></head>
32+
<body>
33+
<p>Paragraph 1</p>
34+
<p>Paragraph 2</p>
35+
<p>Paragraph 3</p>
36+
<p>Paragraph 4</p>
37+
<p>Paragraph 5</p>
38+
<p>Paragraph 6</p>
39+
<p>Paragraph 7</p>
40+
<p>Paragraph 8</p>
41+
</body>
42+
</html>")
4543

4644
(deftest select-next-loc-test
4745
(testing "The select-next-loc function."
@@ -232,7 +230,15 @@ cool\">Span</span>
232230
(= :h1 (-> selection first :tag)))))
233231
(let [selection (select/select (select/find-in-text #"Div") htree)]
234232
(is (and (= 1 (count selection))
235-
(= :div (-> selection first :tag))))))
233+
(= :div (-> selection first :tag)))))
234+
(let [selection-locs (select/select-locs
235+
(select/child (select/tag :body)
236+
(select/find-in-text #"Paragraph"))
237+
htree)
238+
selection (mapv zip/node selection-locs)]
239+
(is (and (= 1 (count selection))
240+
(= :p (-> selection first :tag))
241+
(= :body (-> selection-locs first zip/up zip/node :tag))))))
236242
(let [htree (hickory/as-hickory (hickory/parse html2))]
237243
(let [selection (select/select (select/find-in-text #"Paragraph") htree)]
238244
(is (and (= 8 (count selection))

0 commit comments

Comments
 (0)