1- import  {  nodesToPortableText ,  PortableTextItem ,  traversePortableText  }  from  "../../../src" ; 
1+ import  {  DomNode ,  PortableTextItem ,   transformToPortableText ,  traversePortableText  }  from  "../../../src" ; 
22import  {  browserParse  }  from  "../../../src/parser/browser" ; 
33import  {  nodeParse  }  from  "../../../src/parser/node" ; 
44
@@ -14,21 +14,23 @@ describe("Portable Text Transformer", () => {
1414  const  transformInput  =  ( 
1515    input : string , 
1616  ) : { 
17-     nodeResult : PortableTextItem [ ] ; 
18-     browserResult : PortableTextItem [ ] ; 
17+     nodeTree : DomNode [ ] ; 
18+     browserTree : DomNode [ ] ; 
19+     result : PortableTextItem [ ] ; 
1920  }  =>  { 
2021    const  browserTree  =  browserParse ( input ) ; 
2122    const  nodeTree  =  nodeParse ( input ) ; 
2223    return  { 
23-       nodeResult : nodesToPortableText ( nodeTree ) , 
24-       browserResult : nodesToPortableText ( browserTree ) , 
24+       nodeTree, 
25+       browserTree, 
26+       result : transformToPortableText ( input ) , 
2527    } ; 
2628  } ; 
2729
2830  const  transformAndCompare  =  ( input : string )  =>  { 
29-     const  {  nodeResult ,  browserResult  }  =  transformInput ( input ) ; 
30-     expect ( nodeResult ) . toMatchSnapshot ( ) ; 
31-     expect ( nodeResult ) . toMatchObject ( browserResult ) ; 
31+     const  {  nodeTree ,  browserTree ,  result  }  =  transformInput ( input ) ; 
32+     expect ( result ) . toMatchSnapshot ( ) ; 
33+     expect ( nodeTree ) . toMatchObject ( browserTree ) ; 
3234  } ; 
3335
3436  it ( "transforms empty rich text" ,  ( )  =>  { 
@@ -246,14 +248,10 @@ describe("Portable Text Transformer", () => {
246248    transformAndCompare ( `<p>text<strong>bold</strong></p>` ) ; 
247249  } ) ; 
248250
249-   it . each ( [ nodeParse ,  browserParse ] ) ( 
250-     "throws error for non-supported tags for %s" , 
251-     ( parse )  =>  { 
252-       const  input  =  "<p>text in a paragraph</p><div>text in a div, which doesnt exist in kontent RTE</div>" ; 
253-       const  tree  =  parse ( input ) ; 
254-       expect ( ( )  =>  nodesToPortableText ( tree ) ) . toThrow ( ) ; 
255-     } , 
256-   ) ; 
251+   it ( "throws error for non-supported tags" ,  ( )  =>  { 
252+     const  input  =  "<p>text in a paragraph</p><div>text in a div, which doesnt exist in kontent RTE</div>" ; 
253+     expect ( ( )  =>  transformToPortableText ( input ) ) . toThrow ( ) ; 
254+   } ) ; 
257255
258256  it ( "doesn't extend link mark to adjacent spans" ,  ( )  =>  { 
259257    transformAndCompare ( 
@@ -301,13 +299,14 @@ describe("Portable Text Transformer", () => {
301299      `<object type="application/kenticocloud" data-type="item" data-rel="link" data-codename="test_item"></object>` ; 
302300
303301    const  processBlock  =  ( block : PortableTextItem )  => 
304-       block . _type  ===  "componentOrItem"  ? {  ...block ,  additionalData : "data"  }  : null ; 
302+       block . _type  ===  "componentOrItem" 
303+         ? {  ...block ,  additionalData : "data"  } 
304+         : null ; 
305305
306-     const  {  nodeResult  }  =  transformInput ( input ) ; 
307-     const  modifiedResult  =  traversePortableText ( nodeResult ,  processBlock ) ; 
306+     const  {  result  }  =  transformInput ( input ) ; 
307+     const  modifiedResult  =  traversePortableText ( result ,  processBlock ) ; 
308308
309309    expect ( modifiedResult ) . toMatchSnapshot ( ) ; 
310-     expect ( modifiedResult ) . toMatchObject ( nodeResult ) ; 
311310  } ) ; 
312311
313312  it ( "extends link nested in a table with additional data" ,  ( )  =>  { 
@@ -316,11 +315,10 @@ describe("Portable Text Transformer", () => {
316315    const  processBlock  =  ( block : PortableTextItem )  => 
317316      block . _type  ===  "link"  ? {  ...block ,  additionalData : "data"  }  : null ; 
318317
319-     const  {  nodeResult  }  =  transformInput ( input ) ; 
320-     const  transformedResult  =  traversePortableText ( nodeResult ,  processBlock ) ; 
318+     const  {  result  }  =  transformInput ( input ) ; 
319+     const  transformedResult  =  traversePortableText ( result ,  processBlock ) ; 
321320
322321    expect ( transformedResult ) . toMatchSnapshot ( ) ; 
323-     expect ( transformedResult ) . toMatchObject ( nodeResult ) ; 
324322  } ) ; 
325323
326324  it ( "transforms a linked item and a component from MAPI with corresponding dataType" ,  ( )  =>  { 
0 commit comments