mirror of
https://github.com/msva/lua-htmlparser.git
synced 2024-11-27 12:44:22 +00:00
Separated tests for descendants and children. Fixes #17
This commit is contained in:
parent
fc12dc87e0
commit
f97cde994e
21
tst/init.lua
21
tst/init.lua
@ -6,9 +6,9 @@ local lunitx = require("lunitx")
|
|||||||
module("html", lunitx.testcase, package.seeall)
|
module("html", lunitx.testcase, package.seeall)
|
||||||
|
|
||||||
local htmlparser = require("htmlparser")
|
local htmlparser = require("htmlparser")
|
||||||
|
local tree, sel
|
||||||
|
|
||||||
function test_children()
|
function test_descendants()
|
||||||
local tree, sel
|
|
||||||
tree = htmlparser.parse([[
|
tree = htmlparser.parse([[
|
||||||
<parent>1
|
<parent>1
|
||||||
<child>1.1</child>
|
<child>1.1</child>
|
||||||
@ -25,6 +25,23 @@ function test_children()
|
|||||||
]])
|
]])
|
||||||
sel = tree("parent child")
|
sel = tree("parent child")
|
||||||
assert_equal(6, sel:len(), 'parent child')
|
assert_equal(6, sel:len(), 'parent child')
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_children()
|
||||||
|
tree = htmlparser.parse([[
|
||||||
|
<parent>1
|
||||||
|
<child>1.1</child>
|
||||||
|
<child>1.2
|
||||||
|
<child>1.2.1</child>
|
||||||
|
</child>
|
||||||
|
</parent>
|
||||||
|
<parent>2
|
||||||
|
<child>2.1</child>
|
||||||
|
<child>2.2
|
||||||
|
<child>2.2.1</child>
|
||||||
|
</child>
|
||||||
|
</parent>
|
||||||
|
]])
|
||||||
sel = tree("parent > child")
|
sel = tree("parent > child")
|
||||||
assert_equal(4, sel:len(), 'parent > child')
|
assert_equal(4, sel:len(), 'parent > child')
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user