describe('invalid html', function () { var compareStrings = require('dom-compare').compareStrings, reporter = require('dom-compare').GroupingReporter, chai = require('chai'), assert = chai.assert; var DomParser = require('../index.js'), parser = new DomParser(); it('unclosed tag', function(){ var invalidHTML = '
\n' + '
\n' + ' \n' + '
\n' + '
1
\n' + ' \n' + '
\n' + '
', validHTML = '
\n' + '
\n' + ' \n' + '
\n' + '
1
\n' + '
\n' + '
\n' + '
\n' + '
'; var dom = parser.parseFromString(invalidHTML), ctn = dom.getElementById('root'); var compareResult = compareStrings(ctn.outerHTML, validHTML); assert.equal(compareResult.getResult(), true, reporter.report(compareResult)); }); it ('excess closing tag', function(){ var invalidHTML = '
\n' + ' \n' + '
\n' + '
1
\n' + '
\n' + '
\n' + ' \n' + ' \n' + '
\n' + '
1
\n' + '
\n' + '
\n' + ' \n' + '\n' , validHTML = '
\n' + ' \n' + '
\n' + '
1
\n' + '
\n' + '
\n' + ' \n' + '
\n' + '
1
\n' + '
\n' + '
\n' + '
'; var dom = parser.parseFromString(invalidHTML), ctn = dom.getElementById('root'); var compareResult = compareStrings(ctn.outerHTML, validHTML); assert.equal(compareResult.getResult(), true, reporter.report(compareResult)); }); });