@@ -270,3 +270,38 @@ describe('getNestedValueIfAvailable', () => {
270
270
} ) ;
271
271
272
272
} ) ;
273
+ describe ( "CS-41001" , ( ) => {
274
+ test ( "should not add fragment for text nodes having white spaces" , ( ) => {
275
+ const dom = new JSDOM ( ) ;
276
+ const document = dom . window . document ;
277
+ const body = document . createElement ( "body" ) ;
278
+ const td1 = document . createElement ( "td" ) ;
279
+ const td2 = document . createElement ( "td" ) ;
280
+ const tr = document . createElement ( "tr" ) ;
281
+ const text = document . createTextNode ( ` ` )
282
+ td1 . textContent = "Hello" ;
283
+ td2 . textContent = "World" ;
284
+ tr . appendChild ( td1 ) ;
285
+ tr . append ( text )
286
+ tr . appendChild ( td2 ) ;
287
+ body . append ( tr )
288
+ const jsonValue = fromRedactor ( body ) ;
289
+ expect ( jsonValue ) . toStrictEqual ( { "type" :"doc" , "uid" :"uid" , "attrs" :{ } , "children" :[ { "type" :"tr" , "attrs" :{ } , "uid" :"uid" , "children" :[ { "type" :"td" , "attrs" :{ } , "uid" :"uid" , "children" :[ { "text" :"Hello" } ] } , { "type" :"td" , "attrs" :{ } , "uid" :"uid" , "children" :[ { "text" :"World" } ] } ] } ] } )
290
+ } )
291
+ test ( "should add fragment for text nodes between block nodes" , ( ) => {
292
+ const dom = new JSDOM ( ) ;
293
+ const document = dom . window . document ;
294
+ const body = document . createElement ( "body" ) ;
295
+ const p1 = document . createElement ( "p" ) ;
296
+ const p2 = document . createElement ( "p" ) ;
297
+ const text = document . createTextNode ( ` beautiful ` )
298
+ p1 . textContent = "Hello" ;
299
+ p2 . textContent = "World" ;
300
+ body . appendChild ( p1 ) ;
301
+ body . append ( text )
302
+ body . appendChild ( p2 ) ;
303
+ const jsonValue = fromRedactor ( body ) ;
304
+ expect ( jsonValue ) . toStrictEqual ( { "type" :"doc" , "uid" :"uid" , "attrs" :{ } , "children" :[ { "type" :"p" , "attrs" :{ } , "uid" :"uid" , "children" :[ { "text" :"Hello" } ] } , { "type" :"fragment" , "attrs" :{ } , "uid" :"uid" , "children" :[ { "text" :" beautiful " } ] } , { "type" :"p" , "attrs" :{ } , "uid" :"uid" , "children" :[ { "text" :"World" } ] } ] } )
305
+ } )
306
+ } )
307
+
0 commit comments