Skip to content

Commit 7a9d6b4

Browse files
committed
Update tests for dropping whitespace-only nodes.
1 parent 0b09ab2 commit 7a9d6b4

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

test/parse.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ test('parse', function (t) {
301301
attrs: {},
302302
voidElement: false,
303303
children: []
304-
},{
305-
type: 'text', content: '\n'
306304
}], 'should not explode on trailing whitespace');
307305

308306
html = '<div>Hi</div> There ';
@@ -339,8 +337,6 @@ test('parse', function (t) {
339337
children: [
340338
{ type: 'text', content: 'something' }
341339
]
342-
},{
343-
type: 'text', content: ' '
344340
},{
345341
type: 'tag',
346342
name: 'a',
@@ -351,6 +347,25 @@ test('parse', function (t) {
351347
type: 'text', content: 'else '
352348
}], 'should handle text nodes in the middle of tags at the top-level');
353349

350+
html = '<div>Hi</div>\n\n <span>There</span> \t ';
351+
parsed = HTML.parse(html);
352+
t.deepEqual(parsed, [{
353+
type: 'tag',
354+
name: 'div',
355+
attrs: {},
356+
voidElement: false,
357+
children: [
358+
{ type: 'text', content: 'Hi' }
359+
]
360+
},{
361+
type: 'tag',
362+
name: 'span',
363+
attrs: {},
364+
voidElement: false,
365+
children: [
366+
{ type: 'text', content: 'There' }
367+
]
368+
}], 'should remove text nodes that are nothing but whitespace');
354369
t.end();
355370
});
356371

0 commit comments

Comments
 (0)