From d914efad83817511becf7331f60fd79d1a807446 Mon Sep 17 00:00:00 2001 From: Ron S Date: Sat, 22 May 2021 19:34:51 -0400 Subject: [PATCH] test: Improve testing --- test/html.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/html.js b/test/html.js index 0b898e8..e84c20b 100644 --- a/test/html.js +++ b/test/html.js @@ -126,10 +126,10 @@ describe('HTML Parser', function () { const script = root.firstChild; const style = root.lastChild; script.childNodes.should.not.be.empty; - script.childNodes.should.eql([new TextNode('1', script)]); + 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.childNodes.should.eql([ new TextNode('2&', style) ]); style.text.should.eql('2&'); style.rawText.should.eql('2&'); }); @@ -198,11 +198,16 @@ describe('HTML Parser', function () { describe('#removeWhitespace()', function () { it('should remove whitespaces while preserving nodes with content', function () { - const root = parseHTML('

\r \n \t

123

'); + const root = parseHTML('

\r \n \t

123

'); + + const textNode = new TextNode(' 123 '); + textNode.rawText = textNode.trimmedText; + textNode.rawText.should.eql(' 123 '); const p = new HTMLElement('p', {}, '', root); - p.appendChild(new HTMLElement('h5', {}, '')) - .appendChild(Object.assign(new TextNode('123'), { _trimmedText: '123' })); + p + .appendChild(new HTMLElement('h5', {}, '')) + .appendChild(textNode); root.firstChild.removeWhitespace().should.eql(p); });