Skip to content

Commit b55f9e4

Browse files
added tests and minor fix
1 parent 04ac869 commit b55f9e4

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/api/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ var load = exports.load = function(html) {
244244
};
245245

246246
var html = exports.html = function(dom) {
247-
if (dom !== undefined && dom.length) {
247+
if (dom !== undefined) {
248248
return render(dom);
249249
} else if (this.root && this.root.children) {
250250
return render(this.root.children);

test/api.utils.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var cheerio = require('../'),
2+
should = require('should');
3+
4+
/*
5+
Examples
6+
*/
7+
8+
9+
describe('$', function() {
10+
11+
describe('.html', function() {
12+
13+
it('(html) should return innerHTML of element', function() {
14+
var html = "<div><span>foo</span><span>bar</span></div>",
15+
$ = cheerio.load(html),
16+
span = $('div').children().get(1);
17+
18+
$(span).html().should.equal('bar');
19+
$.html(span).should.equal('<span>bar</span>')
20+
});
21+
});
22+
});

0 commit comments

Comments
 (0)