Skip to content

Commit d914efa

Browse files
committed
test: Improve testing
1 parent 0195dd3 commit d914efa

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/html.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ describe('HTML Parser', function () {
126126
const script = root.firstChild;
127127
const style = root.lastChild;
128128
script.childNodes.should.not.be.empty;
129-
script.childNodes.should.eql([new TextNode('1', script)]);
129+
script.childNodes.should.eql([ new TextNode('1', script) ]);
130130
script.text.should.eql('1');
131131
style.childNodes.should.not.be.empty;
132-
style.childNodes.should.eql([new TextNode('2&', style)]);
132+
style.childNodes.should.eql([ new TextNode('2&', style) ]);
133133
style.text.should.eql('2&');
134134
style.rawText.should.eql('2&');
135135
});
@@ -198,11 +198,16 @@ describe('HTML Parser', function () {
198198

199199
describe('#removeWhitespace()', function () {
200200
it('should remove whitespaces while preserving nodes with content', function () {
201-
const root = parseHTML('<p> \r \n \t <h5>123</h5></p>');
201+
const root = parseHTML('<p> \r \n \t <h5> 123 </h5></p>');
202+
203+
const textNode = new TextNode(' 123 ');
204+
textNode.rawText = textNode.trimmedText;
205+
textNode.rawText.should.eql(' 123 ');
202206

203207
const p = new HTMLElement('p', {}, '', root);
204-
p.appendChild(new HTMLElement('h5', {}, ''))
205-
.appendChild(Object.assign(new TextNode('123'), { _trimmedText: '123' }));
208+
p
209+
.appendChild(new HTMLElement('h5', {}, ''))
210+
.appendChild(textNode);
206211

207212
root.firstChild.removeWhitespace().should.eql(p);
208213
});

0 commit comments

Comments
 (0)