add test: querySelector

This commit is contained in:
taoqiufeng 2017-06-16 09:58:05 +08:00
parent 63b4915a86
commit cb8acf5094

View file

@ -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 () {
it('should return correct elements in DOM tree', function () {