var expect = require('expect.js'), _ = require('lodash'), cheerio = require('..'); var xml = function(str, options) { options = _.extend({ xmlMode: true }, options); var dom = cheerio.load(str, options); return dom.xml(); }; var dom = function(str, options) { var $ = cheerio.load('', options); return $(str).html(); }; describe('render', function() { describe('(xml)', function() { it('should render tags correctly', function() { var str = ''; expect(xml(str)).to.equal(''); }); it('should render tags (RSS) correctly', function() { var str = 'http://www.github.com/'; expect(xml(str)).to.equal('http://www.github.com/'); }); it('should escape entities', function(){ var str = ''; expect(xml(str)).to.equal(str); }); }); describe('(dom)', function () { it('should keep camelCase for new nodes', function() { var str = 'hello'; expect(dom(str, {xmlMode: false})).to.equal('hello'); }); it('should keep camelCase for new nodes', function() { var str = 'hello'; expect(dom(str, {xmlMode: true})).to.equal('hello'); }); it('should maintain the parsing options of distinct contexts independently', function() { var str = 'hello'; var $x = cheerio.load('', { xmlMode: false }); expect($x(str).html()).to.equal('hello'); }); }); });