Skip to content

Commit

Permalink
test: Improve testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nonara committed May 22, 2021
1 parent 0195dd3 commit d914efa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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&');
});
Expand Down Expand Up @@ -198,11 +198,16 @@ describe('HTML Parser', function () {

describe('#removeWhitespace()', function () {
it('should remove whitespaces while preserving nodes with content', function () {
const root = parseHTML('<p> \r \n \t <h5>123</h5></p>');
const root = parseHTML('<p> \r \n \t <h5> 123 </h5></p>');

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);
});
Expand Down

0 comments on commit d914efa

Please sign in to comment.