import { expect } from 'chai'; import { DOMParserImpl } from '../../src/parser/dom-parser'; describe('XML Error tests', () => { it('empty document', () => { const errors: string[] = []; const p = new DOMParserImpl({ errorHandler: function(_key, msg) { errors.push(msg); }, }); p.parseFromString('', 'text/xml'); expect(errors).to.not.have.length(0, 'empty document error unreported'); }); it('unclosed document', () => { const errors: string[] = []; const p = new DOMParserImpl({ errorHandler: function(_key, msg) { errors.push(msg); }, }); p.parseFromString('', 'text/xml'); expect(errors).to.not.have.length(0, 'unclosed tag error unreported'); }); it('unclosed xml', () => { const errors: string[] = []; const p = new DOMParserImpl({ errorHandler: function(_key, msg) { errors.push(msg); }, }); p.parseFromString('', 'text/html'); expect(errors).to.have.length(0, 'unclosed html tag not need report'); }); it('invalid xml node', () => { const errors: string[] = []; const p = new DOMParserImpl({ errorHandler: function(_key, msg) { errors.push(msg); }, }); let dom = new DOMParserImpl({ errorHandler: () => {}, }).parseFromString('