mirror of
https://github.com/danbulant/node-html-parser
synced 2026-06-19 14:41:10 +00:00
add test: querySelector
This commit is contained in:
parent
63b4915a86
commit
cb8acf5094
1 changed files with 17 additions and 0 deletions
17
test/html.js
17
test/html.js
|
|
@ -222,6 +222,23 @@ describe('HTML Parser', function () {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#querySelector()', function () {
|
||||||
|
|
||||||
|
it('should return correct elements in DOM tree', function () {
|
||||||
|
|
||||||
|
var root = parseHTML('<a id="id"><div><span class="a b"></span><span></span><span></span></div></a>');
|
||||||
|
|
||||||
|
root.querySelector('#id').should.eql(root.firstChild);
|
||||||
|
root.querySelector('span.a').should.eql(root.firstChild.firstChild.firstChild);
|
||||||
|
root.querySelector('span.b').should.eql(root.firstChild.firstChild.firstChild);
|
||||||
|
root.querySelector('span.a.b').should.eql(root.firstChild.firstChild.firstChild);
|
||||||
|
root.querySelector('#id .b').should.eql(root.firstChild.firstChild.firstChild);
|
||||||
|
root.querySelector('#id span').should.eql(root.firstChild.firstChild.firstChild);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe('#querySelectorAll()', function () {
|
describe('#querySelectorAll()', function () {
|
||||||
|
|
||||||
it('should return correct elements in DOM tree', function () {
|
it('should return correct elements in DOM tree', function () {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue