@@ -126,10 +126,10 @@ describe('HTML Parser', function () {
126
126
const script = root . firstChild ;
127
127
const style = root . lastChild ;
128
128
script . childNodes . should . not . be . empty ;
129
- script . childNodes . should . eql ( [ new TextNode ( '1' , script ) ] ) ;
129
+ script . childNodes . should . eql ( [ new TextNode ( '1' , script ) ] ) ;
130
130
script . text . should . eql ( '1' ) ;
131
131
style . childNodes . should . not . be . empty ;
132
- style . childNodes . should . eql ( [ new TextNode ( '2&' , style ) ] ) ;
132
+ style . childNodes . should . eql ( [ new TextNode ( '2&' , style ) ] ) ;
133
133
style . text . should . eql ( '2&' ) ;
134
134
style . rawText . should . eql ( '2&' ) ;
135
135
} ) ;
@@ -198,11 +198,16 @@ describe('HTML Parser', function () {
198
198
199
199
describe ( '#removeWhitespace()' , function ( ) {
200
200
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 ' ) ;
202
206
203
207
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 ) ;
206
211
207
212
root . firstChild . removeWhitespace ( ) . should . eql ( p ) ;
208
213
} ) ;
0 commit comments