const should = require('should'); const fs = require('fs'); const { parse: parseHTML, HTMLElement, TextNode, CommentNode } = require('@test/test-target'); describe('HTML Parser', function () { describe('parse()', function () { it('should parse "

Hello

" and return root element', function () { const root = parseHTML('

Hello

'); const p = new HTMLElement('p', { id: 'id' }, 'id="id"'); p.appendChild(new HTMLElement('a', { class: 'cls' }, 'class=\'cls\'')) .appendChild(new TextNode('Hello')); const ul = p.appendChild(new HTMLElement('ul', {}, '')); ul.appendChild(new HTMLElement('li', {}, '')); ul.appendChild(new HTMLElement('li', {}, '')); p.appendChild(new HTMLElement('span', {}, '')); root.firstChild.toString().should.eql(p.toString()); // root.firstChild.should.eql(p); }); it('should parse "

" and return root element', function () { const root = parseHTML('

', { lowerCaseTagName: true }); const u = undefined; const div = new HTMLElement('div', {}, '', root, u, u, { lowerCaseTagName: true }); const a = div.appendChild(new HTMLElement('a', {}, '', u, u, u, { lowerCaseTagName: true })); const img = a.appendChild(new HTMLElement('img', {}, '', u, u, u, { lowerCaseTagName: true })); const p = div.appendChild(new HTMLElement('p', {}, '', u, u, u, { lowerCaseTagName: true })); root.firstChild.should.eql(div); }); it.skip('TODO implement: should use HTMLElement._defaultParseOptions', function () { // set _defaultParseOptions, // so we dont have to pass parseOptions to every `new HTMLElement(...)` // FIXME _defaultParseOptions is not used should(HTMLElement._defaultParseOptions.lowerCaseTagName).be.undefined(); HTMLElement._defaultParseOptions.lowerCaseTagName = true; const root = parseHTML('

'); const div = new HTMLElement('div', {}, '', root); const a = div.appendChild(new HTMLElement('a', {}, '')); const img = a.appendChild(new HTMLElement('img', {}, '')); const p = div.appendChild(new HTMLElement('p', {}, '')); root.firstChild.should.eql(div); // cleanup? remove key from _defaultParseOptions object? //HTMLElement._defaultParseOptions.lowerCaseTagName = undefined; }); it('should deal uppercase', function () { //should(HTMLElement._defaultParseOptions.comment).be.undefined(); const html = 'SISREG III

CONSULTA AO CADASTRO DE PACIENTES SUS



Processando...


'; const root = parseHTML(html, { lowerCaseTagName: true }); root.toString().should.eql('SISREG III

CONSULTA AO CADASTRO DE PACIENTES SUS



Processando...


'); // root.toString().firstChild.should.eql(div); }); it('should parse "

" and return root element', function () { const root = parseHTML('

'); const div = new HTMLElement('div', {}, '', root); const a = div.appendChild(new HTMLElement('a', {}, '')); const img = a.appendChild(new HTMLElement('img', {}, '')); const p = div.appendChild(new HTMLElement('p', {}, '')); root.firstChild.should.eql(div); }); it('should parse "
" and return root element without comments', function () { const root = parseHTML('
'); const div = new HTMLElement('div', {}, '', root); const a = div.appendChild(new HTMLElement('a', {}, '')); root.firstChild.should.eql(div); }); it('should parse "
" and return root element with comments', function () { const root = parseHTML('
', { comment: true }); const u = undefined; const div = new HTMLElement('div', {}, '', root, u, u, { comment: true }); const a = div.appendChild(new HTMLElement('a', {}, '', u, u, u, { comment: true })); const comment = a.appendChild(new CommentNode(' my comment ', u, u, u, u, u, { comment: true })); root.firstChild.should.eql(div); }); it('should not parse HTML inside comments', function () { const root = parseHTML('
', { comment: true }); const u = undefined; const div = new HTMLElement('div', {}, '', root, u, u, { comment: true }); const comment = div.appendChild(new CommentNode('', u, u, u, u, u, { comment: true })); root.firstChild.should.eql(div); }); // yarn test:target -g 'should parse HTML comments in *' it('should parse HTML comments in insertAdjacentHTML', function () { const root = parseHTML('
', { comment: true }); const div = root.querySelector('div'); div.insertAdjacentHTML('afterend', ''); root.toString().should.eql('
'); div.nextSibling.toString().should.eql(''); }); it('should parse HTML comments in set innerHTML', function () { const root = parseHTML('
', { comment: true }); const div = root.querySelector('div'); div.innerHTML = ''; root.toString().should.eql('
'); div.firstChild.toString().should.eql(''); }); it('should parse HTML comments in set_content', function () { const root = parseHTML('
', { comment: true }); const div = root.querySelector('div'); div.set_content(''); root.toString().should.eql('
'); div.firstChild.toString().should.eql(''); }); it('should parse HTML comments in set_content - comment in div', function () { const root = parseHTML('
', { comment: true }); const div = root.querySelector('div'); div.set_content('
'); root.toString().should.eql('
'); div.firstChild.toString().should.eql('
'); }); it('should parse HTML comments NOT in set_content with option comment=false', function () { const root = parseHTML('
', { comment: true }); const div = root.querySelector('div'); div.set_content('', { comment: false }); root.toString().should.eql('
'); }); it('should parse HTML comments NOT in set_content with option comment=false - comment in div', function () { const root = parseHTML('
', { comment: true }); const div = root.querySelector('div'); div.set_content('
', { comment: false }); root.toString().should.eql('
'); }); it('should parse HTML comments in replaceWith', function () { const root = parseHTML('
', { comment: true }); const div = root.querySelector('div'); div.replaceWith(''); root.toString().should.eql(''); }); it('should parse HTML comments in clone', function () { const root = parseHTML('
', { comment: true }); const div = root.querySelector('div'); const clone = div.clone(); clone.toString().should.eql('
'); }); it('should parse picture element', function () { const root = parseHTML('Example'); const picture = new HTMLElement('picture', {}, '', root); const source = picture.appendChild(new HTMLElement('source', {}, 'srcset="/images/example-1.jpg 1200w, /images/example-2.jpg 1600w" sizes="100vw"')); const img = picture.appendChild(new HTMLElement('img', {}, 'src="/images/example.jpg" alt="Example"')); root.firstChild.should.eql(picture); }); it('should not extract text in script and style by default', function () { const root = parseHTML(''); root.firstChild.childNodes.should.be.empty; root.lastChild.childNodes.should.be.empty; }); it('should extract text in script and style when ask so', function () { const root = parseHTML('', { script: true, style: true }); const script = root.firstChild; const style = root.lastChild; script.childNodes.should.not.be.empty; script.childNodes.should.eql([new TextNode('1', script)]); script.text.should.eql('1'); style.childNodes.should.not.be.empty; style.childNodes.should.eql([new TextNode('2&', style)]); style.text.should.eql('2&'); style.rawText.should.eql('2&'); }); it('should be able to parse "html/incomplete-script" file', function () { const root = parseHTML(fs.readFileSync(__dirname + '/../assets/html/incomplete-script').toString(), { script: true }); }); it('should be able to parse namespaces', function () { const namespacedXML = 'content'; parseHTML(namespacedXML).toString().should.eql(namespacedXML); }); it('should parse "

.." very fast', function () { for (let i = 0; i < 100; i++) parseHTML('

'); }); it('should parse "

.." fast', function () { for (let i = 0; i < 100; i++) parseHTML('

', { lowerCaseTagName: true }); }); // Test for broken tags.

something

it('should parse "

content

other

" (fix h3, span closing tag) very fast', function () { const root = parseHTML(fs.readFileSync(__dirname + '/../assets/html/incomplete-script').toString()); }); it('should parse table currect', function () { this.timeout(4000); // pass test on slow CPUs const root = parseHTML(fs.readFileSync(__dirname + '/../assets/html/tables.html').toString(), { script: true }); const tables = root.querySelectorAll('table'); tables.length.should.eql(3176); }); }); describe('TextNode', function () { it('#isWhitespace', function () { let node = new TextNode(''); node.isWhitespace.should.be.ok; node = new TextNode(' \t'); node.isWhitespace.should.be.ok; node = new TextNode(' \t  \t'); node.isWhitespace.should.be.ok; }); it('parse text node', function () { const result = parseHTML('hello mmstudio'); result.firstChild.should.instanceOf(TextNode); result.toString().should.eql('hello mmstudio'); }); }); describe('HTMLElement', function () { describe('#removeWhitespace()', function () { it('should remove whitespaces while preserving nodes with content', function () { const root = parseHTML('

\r \n \t

123 

'); const textNode = new TextNode(' 123  '); textNode.rawText = textNode.trimmedRawText; textNode.rawText.should.eql(' 123  '); const p = new HTMLElement('p', {}, '', root); p .appendChild(new HTMLElement('h5', {}, '')) .appendChild(textNode); root.firstChild.removeWhitespace().should.eql(p); }); it('should preserve legitimate leading/trailing whitespace in TextNode', function () { parseHTML('

Hello World!

').removeWhitespace().firstChild.text.should.eql('Hello World!'); parseHTML('

\t\nHello\n\tWorld!

').removeWhitespace().firstChild.text.should.eql('HelloWorld!'); parseHTML('

\t\n Hello \n\tWorld!

').removeWhitespace().firstChild.text.should.eql(' Hello World!'); }); it('should preserve consecutive backslashes in attribute values', function () { const html = 'x'; parseHTML(html).removeWhitespace().firstChild.toString().should.eql(html); }); it('should preserve valueless attributes', function () { parseHTML('').removeWhitespace().firstChild.toString().should.eql(''); }); }); describe('#rawAttributes', function () { it('should return escaped attributes of the element', function () { const root = parseHTML('

'); root.firstChild.rawAttributes.should.eql({ 'a': '12', 'data-id': '!$$&', 'yAz': '1', '@click': 'doSmt()' }); }); }); describe('#attributes', function () { it('should return attributes of the element', function () { const root = parseHTML('

'); root.firstChild.attributes.should.eql({ 'a': '12', 'data-id': '!$$&', 'yAz': '1', 'disabled': '', 'class': '' }); }); }); describe('#getAttribute', function () { it('should return value of the attribute', function () { const root = parseHTML('

'); root.firstChild.getAttribute('a').should.eql('a1b'); }); it('should return value of the first attribute', function () { const root = parseHTML('

'); root.firstChild.getAttribute('a').should.eql('a1b'); }); it('should return null when there is no such attribute', function () { const root = parseHTML('

'); should.equal(root.firstChild.getAttribute('b'), null); }); it('should return empty string as broser behavior', function () { const root = parseHTML(''); const input = root.firstChild; input.getAttribute('required').should.eql(''); }); it('should return null as browser behavior', function () { const root = parseHTML(''); const input = root.firstChild; input.getAttribute('required').should.eql(''); input.setAttribute('readonly', null); input.getAttribute('readonly').should.eql('null'); input.setAttribute('disabled', ''); input.getAttribute('disabled').should.eql(''); input.toString().should.eql('') }); }); describe('#setAttribute', function () { it('should edit the attributes of the element', function () { const root = parseHTML('

'); const attr1 = root.firstChild.attributes; attr1.should.eql({ 'a': '12', }); root.firstChild.setAttribute('a', 13); const attr2 = root.firstChild.attributes; attr2.should.eql({ 'a': '13', }); root.firstChild.getAttribute('a').should.eql('13'); root.firstChild.toString().should.eql('

'); }); it('should add an attribute to the element', function () { const root = parseHTML('

'); root.firstChild.setAttribute('b', 13); root.firstChild.attributes.should.eql({ 'a': '12', 'b': '13', }); root.firstChild.toString().should.eql('

'); root.firstChild.setAttribute('required', ''); root.firstChild.toString().should.eql('

'); }); it('should convert value to string', function () { const root = parseHTML('

'); const p = root.firstChild; p.setAttribute('b', null); p.setAttribute('c', undefined); p.getAttribute('b').should.eql('null'); p.getAttribute('c').should.eql('undefined'); p.toString().should.eql('

'); }); it('should throw type Error', function () { const root = parseHTML('

'); const p = root.firstChild; should.throws(function () { p.setAttribute('b') }); should.throws(function () { p.setAttribute() }); }); it('should keep quotes arount value', function () { const root = parseHTML('

'); root.firstChild.setAttribute('b', 13); root.firstChild.setAttribute('c', '2'); root.firstChild.attributes.should.eql({ 'a': '12', 'b': '13', 'c': '2' }); root.firstChild.toString().should.eql('

'); }); }); describe('#setAttributes', function () { it('should return attributes of the element', function () { const root = parseHTML('

'); root.firstChild.setAttributes({ c: 12, d: '&&<>foo' }); root.firstChild.attributes.should.eql({ 'c': '12', d: '&&<>foo' }); root.firstChild.toString().should.eql('

'); // root.firstChild.toString().should.eql('

'); }); }); describe('#removeAttribute', function () { it('should remove attribute required', function () { const root = parseHTML(''); const input = root.firstChild; input.removeAttribute('required'); input.toString().should.eql(''); }); }); describe('#hasAttribute', function () { it('should return true or false when has or has not some attribute', function () { const root = parseHTML(''); const input = root.firstChild; input.hasAttribute('required').should.eql(true); input.removeAttribute('required'); input.hasAttribute('required').should.eql(false); }); }); describe('#structuredText', function () { it('should return correct structured text', function () { const root = parseHTML('o

a

b

c
'); root.structuredText.should.eql('o\na\nb\nc'); }); it('should not return comments in structured text', function () { const root = parseHTML('o

a

', { comment: true }); root.structuredText.should.eql('o\na'); }); it('should return correct structured text (block level elements)', function () { const root = parseHTML('

content

inside

html
'); root.structuredText.should.eql('content\ninside\nhtml'); }); it('should not indent blocks that are separated by whitespace-only text (pretty-printed HTML)', function () { const root = parseHTML( '
\n

Title

\n

First para

\n

Second bold para

\n \n
' ); root.structuredText.should.eql('Title\nFirst para\nSecond bold para\none\ntwo'); }); it('should not add a leading space to a block that follows a whitespace-only text node', function () { parseHTML('

a

b

').structuredText.should.eql('a\nb'); }); it('should not leave a trailing space on the line before a
', function () { parseHTML('

a
b

').structuredText.should.eql('a\nb'); }); it('should still keep a single space between inline elements', function () { parseHTML('
hello w x
').structuredText.should.eql('hello w x'); parseHTML('

x

\ny z').structuredText.should.eql('x\ny z'); }); }); describe('#set_content', function () { it('set content string', function () { const root = parseHTML('
'); root.childNodes[0].set_content('
abc
bla
'); root.toString().should.eql('
abc
bla
'); }); it('set content nodes', function () { const root = parseHTML('
'); root.childNodes[0].set_content(parseHTML('
abc
bla
').childNodes); root.toString().should.eql('
abc
bla
'); }); it('set content node', function () { const root = parseHTML('
'); root.childNodes[0].set_content(parseHTML('
abc
bla
').childNodes[0]); root.toString().should.eql('
abc
bla
'); }); it('set content text', function () { const root = parseHTML('
'); root.childNodes[0].set_content('abc'); root.toString().should.eql('
abc
'); }); it('set content pre', function () { const root = parseHTML(``); const body = root.querySelector("body"); body.set_content(`
this    is some    preformatted    text
`); root.toString().should.eql('
this    is some    preformatted    text
') }); }); describe('encode/decode', function () { it('should decode attributes value', function () { const root = parseHTML('Verissimo, Ilaria D'Amico: «Sogno una bambina. Buffon mi ha chiesto in moglie tante volte»'); root.firstChild.getAttribute('alt').should.eql(`Verissimo, Ilaria D'Amico: «Sogno una bambina. Buffon mi ha chiesto in moglie tante volte»`); root.firstChild.attributes.alt.should.eql(`Verissimo, Ilaria D'Amico: «Sogno una bambina. Buffon mi ha chiesto in moglie tante volte»`); root.firstChild.setAttribute('alt', '«Sogno'); root.firstChild.getAttribute('alt').should.eql('«Sogno'); root.firstChild.rawAttributes.alt.should.eql('«Sogno'); }); it('should not decode text from parseHTML()', function () { // https://github.com/taoqf/node-html-parser/issues/33 const content = `<p> Not a p tag <br /> at all`; const root = parseHTML(`
${content}
`); root.childNodes.should.have.length(1); const divNode = root.firstChild; divNode.childNodes.should.have.length(1); const textNode = divNode.firstChild; textNode.rawText.should.eql(content); }); it(`should decode for node text property`, function () { const encodedText = `My>text`; const decodedText = `My>text`; const root = parseHTML(`

${encodedText}

`); const pNode = root.firstChild; pNode.text.should.eql(decodedText); pNode.rawText.should.eql(encodedText); const textNode = pNode.firstChild; textNode.text.should.eql(decodedText); textNode.rawText.should.eql(encodedText); }); }); describe('#insertAdjacentHTML() should parse and insert childrens', function () { it('shoud insert children after current node', function () { const html = ''; const root = parseHTML(html); const a = root.firstChild; const b = a.firstChild; b.insertAdjacentHTML('afterend', ''); a.toString().should.eql(''); }); it('shoud insert children before current node', function () { const html = ''; const root = parseHTML(html); const b = root.querySelector('b'); b.insertAdjacentHTML('beforebegin', ''); root.toString().should.eql(''); }); it('shoud append children in current node', function () { const html = ''; const root = parseHTML(html); const a = root.firstChild; a.insertAdjacentHTML('beforeend', ''); a.toString().should.eql(''); a.insertAdjacentHTML('beforeend', ''); a.toString().should.eql(''); }); it('shoud insert children at position 0', function () { const html = ''; const root = parseHTML(html); const a = root.firstChild; a.insertAdjacentHTML('afterbegin', ''); a.toString().should.eql(''); a.insertAdjacentHTML('afterbegin', ''); a.toString().should.eql(''); }); it('shoud insert text child at position 0', function () { const html = ''; const root = parseHTML(html); const a = root.firstChild; a.insertAdjacentHTML('afterbegin', 'abc'); a.toString().should.eql('abc'); }); }); describe('Base insertion operations', () => { describe('#before', () => { it('Should insert multiple nodes in order', () => { const root = parseHTML(`
`); root.children[0].before(new HTMLElement('span', {}), new HTMLElement('p', {})); root.childNodes.length.should.eql(3); root.childNodes[0].tagName.should.eql('SPAN'); root.childNodes[1].tagName.should.eql('P'); }); it('Should insert strings as TextNode', () => { const root = parseHTML(`
`); root.children[0].before(new HTMLElement('span', {}), 'foobar', new HTMLElement('p', {})); root.childNodes.length.should.eql(4); root.childNodes[1].should.be.an.instanceof(TextNode); root.childNodes[1].text.should.eql('foobar'); }); it('Should set the parent correctly', () => { const root = parseHTML(`
`); root.firstElementChild.before('foobar'); root.firstElementChild.parentNode.should.eql(root); }); it('Should be removed from previous trees', () => { const root1 = parseHTML(`
`); const root2 = parseHTML(`
`); const section1 = root1.firstElementChild; const section2 = root2.firstElementChild; const div1 = section1.firstElementChild; section2.before(div1); section1.childNodes.length.should.eql(0); root2.childNodes.length.should.eql(2); div1.parentNode.should.eql(root2); }); }); describe('#after', () => { it('Should insert multiple nodes in order', () => { const root = parseHTML(`
`); root.children[0].after(new HTMLElement('span', {}), 'foobar', new HTMLElement('p', {})); root.childNodes.length.should.eql(4); root.childNodes[1].tagName.should.eql('SPAN'); root.childNodes[2].should.be.an.instanceof(TextNode); root.childNodes[3].tagName.should.eql('P'); }); it('Should set the parent correctly', () => { const root = parseHTML(`
`); root.firstElementChild.after('foobar'); root.lastElementChild.parentNode.should.eql(root); }); }); describe('#prepend', () => { it('Should insert multiple nodes in order', () => { const root = parseHTML(`
`); const section = root.firstElementChild; section.prepend(new HTMLElement('span', {}), 'foobar', new HTMLElement('p', {})); section.childNodes.length.should.eql(5); section.childNodes[0].tagName.should.eql('SPAN'); section.childNodes[1].should.be.an.instanceof(TextNode); section.childNodes[2].tagName.should.eql('P'); }); it('Should set the parent correctly', () => { const root = parseHTML(`
`); const section = root.firstElementChild; section.prepend('foobar'); section.childNodes[0].parentNode.should.eql(section); }); }); describe('#append', () => { it('Should insert multiple nodes in order', () => { const root = parseHTML(`
`); const section = root.firstElementChild; section.append(new HTMLElement('span', {}), 'foobar', new HTMLElement('p', {})); section.childNodes.length.should.eql(5); section.childNodes[2].tagName.should.eql('SPAN'); section.childNodes[3].should.be.an.instanceof(TextNode); section.childNodes[4].tagName.should.eql('P'); }); it('Should set the parent correctly', () => { const root = parseHTML(`
`); const section = root.firstElementChild; section.append('foobar'); section.childNodes[0].parentNode.should.eql(section); }); }); }); describe('#removeChild', function () { it('should remove child node', function () { const html = ''; const root = parseHTML(html); const a = root.firstChild; const b = a.firstChild; a.childNodes.length.should.eql(1); a.removeChild(b); a.childNodes.length.should.eql(0); }); it('should not remove child node which does not exist', function () { const html = ''; const root = parseHTML(html); const a = root.firstChild; const b = a.firstChild; const c = b.firstChild; a.childNodes.length.should.eql(1); a.removeChild(c); a.childNodes.length.should.eql(1); }); }); describe('#getElementsByTagName', function () { it('find the divs in proper order', function () { const root = parseHTML(`
`); const divs = root.getElementsByTagName('div'); for (const div of divs) { div.tagName.should.eql('DIV'); } // the literal appearance order divs[0].attributes['data-test'].should.eql('1.0'); divs[1].attributes['data-test'].should.eql('1.1'); divs[2].attributes['data-test'].should.eql('1.1.1'); divs[3].attributes['data-test'].should.eql('2.0'); }); // check that really only children are found, no parents or anything it('only return relevant items', function () { const root = parseHTML(`
`); const divs = root.querySelector('#suit').getElementsByTagName('div'); divs.length.should.eql(2); for (const div of divs) { div.attributes['data-ignore'].should.eql('false'); } }); it('return all elements if tagName is *', function () { const root = parseHTML(`

`); const items = root.getElementsByTagName('*'); items.length.should.eql(4); items[0].tagName.should.eql('SECTION'); items[1].tagName.should.eql('DIV'); items[2].tagName.should.eql('SPAN'); items[3].tagName.should.eql('P'); }); it('return an empty array if nothing is found', function () { const root = parseHTML('
'); root.getElementsByTagName('div').length.should.eql(0); }); it('allow sparse arrays', function () { const root = parseHTML(`
`); delete root.querySelector('section').childNodes[1]; root.getElementsByTagName('div').length.should.eql(2); }); }); describe('#children', () => { const root = parseHTML(`
Text
foobar baz
`); it('All children are `HTMLElement`', () => { root.children.forEach(child => { child.should.be.an.instanceof(HTMLElement); }); }); it('Correct length', () => { root.children.length.should.eql(3); }); }); describe('#matches', () => { it('`HTMLElement` should match CSS selector', () => { const html = parseHTML(`
`); html.firstChild.matches('.example-class').should.be.true(); html.firstChild.matches('#example-id').should.be.true(); html.firstChild.matches('div').should.be.true(); html.firstChild.matches('[data-test="example-data"]').should.be.true(); }); it('`HTMLElement` should not match CSS selector ', () => { const html = parseHTML(`
`); html.firstChild.matches('.no-match').should.be.false(); html.firstChild.matches('#no-match').should.be.false(); html.firstChild.matches('span').should.be.false(); html.firstChild.matches('[data-test="no-match"]').should.be.false(); }); }); }); describe('stringify', function () { it('#toString()', function () { const html = '

Hello

bbb

'; const root = parseHTML(html); root.toString().should.eql(html) }); it('#toString() should not return comments by default', function () { const html = '

'; const result = '

'; const root = parseHTML(html); root.toString().should.eql(result); }); it('#toString() should return comments when specified', function () { const html = '

'; const root = parseHTML(html, { comment: true }); root.toString().should.eql(html); }); it('#toString() should contains id and classnames', function () { const el = new HTMLElement('div', { 'id': 'new_container', 'class': 'container' }); el.id.should.eql('new_container'); el.classNames.should.eql('container'); el.toString().should.eql('
'); }); it('#toString() should contains classnames withspaces', function () { const el = new HTMLElement('div', { 'class': 'container1 container2' }); el.classNames.should.eql('container1 container2'); el.toString().should.eql('
'); }); }); describe('Comment Element', function () { it('comment nodeType should be 8', function () { const root = parseHTML('', { comment: true }); root.firstChild.nodeType.should.eql(8); }); }); describe('Custom Element', function () { it('parse "" tagName should be "my-widget"', function () { const root = parseHTML(''); root.firstChild.tagName.should.eql('MY-WIDGET'); }); }); describe('Custom Element multiple dash', function () { it('parse "" tagName should be "my-new-widget"', function () { const root = parseHTML(''); root.firstChild.tagName.should.eql('MY-NEW-WIDGET'); }); }); });