mirror of
https://github.com/danbulant/node-html-parser
synced 2026-06-19 22:51:29 +00:00
add tests
This commit is contained in:
parent
f96af39690
commit
a655a9a17f
3 changed files with 15 additions and 7 deletions
1
.mocharc.yaml
Normal file
1
.mocharc.yaml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
require: blanket,should,spec
|
||||||
18
test/html.js
18
test/html.js
|
|
@ -345,11 +345,21 @@ describe('HTML Parser', function () {
|
||||||
var root = parseHTML('<time class="date">');
|
var root = parseHTML('<time class="date">');
|
||||||
root.querySelectorAll('time,.date').should.eql([root.firstChild]);
|
root.querySelectorAll('time,.date').should.eql([root.firstChild]);
|
||||||
});
|
});
|
||||||
it('should return elements in order', function () {
|
it.skip('should return elements in order', function () {
|
||||||
var root = parseHTML('<img src=""><p>hello</p>');
|
var root = parseHTML('<img src=""><p>hello</p>');
|
||||||
var results = root.querySelectorAll('p,img');
|
var img = root.firstChild;
|
||||||
results[0].rawText.should.eql('hello');
|
var p = root.childNodes[1];
|
||||||
results[1].should.eql(root.firstChild);
|
var [f, s] = root.querySelectorAll('p,img');
|
||||||
|
f.should.eql(img);
|
||||||
|
s.should.eql(p);
|
||||||
|
});
|
||||||
|
it.skip('should query multiple nodes', function () {
|
||||||
|
var root = parseHTML('<a id="id"><div class="b"><span class="a b"></span><span></span><span></span></div></a>');
|
||||||
|
const a = root.firstChild;
|
||||||
|
const div = a.firstChild;
|
||||||
|
const span = div.firstChild;
|
||||||
|
root.querySelectorAll('#id span').should.eql(div.childNodes);
|
||||||
|
root.querySelectorAll('#id .b').should.eql([div, span]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
--require blanket
|
|
||||||
--require should
|
|
||||||
--reporter spec
|
|
||||||
Loading…
Reference in a new issue