@@ -19,18 +19,35 @@ const imgNode: Node = {
1919
2020}
2121
22+ const imgNodeWithURL : Node = {
23+ type : NodeType . IMAGE ,
24+ attrs : { url : "https://image.url/Donald.jog.png" } ,
25+ children :[ ]
26+
27+ }
28+
2229const linkNode : Node = {
2330 type : NodeType . LINK ,
2431 attrs : { href : "https://image.url/Donald.jog.png" } ,
2532 children :[ ]
2633
2734}
2835
36+ const linkNodeWithURL : Node = {
37+ type : NodeType . LINK ,
38+ attrs : { url : "https://image.url/Donald.jog.png" } ,
39+ children :[ ]
40+
41+ }
42+
2943const embedNode : Node = {
3044 type : NodeType . EMBED ,
31- "attrs" : {
32- src : "https://www.youtube.com/"
33- } ,
45+ attrs : { src : "https://www.youtube.com/" } ,
46+ children : [ ]
47+ }
48+ const embedNodeWithURL : Node = {
49+ type : NodeType . EMBED ,
50+ attrs : { url : "https://www.youtube.com/" } ,
3451 children : [ ]
3552}
3653
@@ -54,6 +71,15 @@ describe('Default node render options', () => {
5471 expect ( renderString ) . toEqual ( '<iframe src="https://www.youtube.com/">text</iframe>' )
5572 done ( )
5673 } )
74+ it ( 'Should return link string with url as attr' , done => {
75+ let renderString = ( defaultNodeOption [ NodeType . LINK ] as RenderNode ) ( linkNodeWithURL , next )
76+ expect ( renderString ) . toEqual ( `<a href="${ linkNodeWithURL . attrs . url } ">text</a>` )
77+ renderString = ( defaultNodeOption [ NodeType . IMAGE ] as RenderNode ) ( imgNodeWithURL , next )
78+ expect ( renderString ) . toEqual ( `<img src="${ imgNodeWithURL . attrs . url } " />text` )
79+ renderString = ( defaultNodeOption [ NodeType . EMBED ] as RenderNode ) ( embedNodeWithURL , next )
80+ expect ( renderString ) . toEqual ( `<iframe src="${ embedNodeWithURL . attrs . url } ">text</iframe>` )
81+ done ( )
82+ } )
5783 it ( 'Should return Heading string' , done => {
5884 let renderString = ( defaultNodeOption [ NodeType . HEADING_1 ] as RenderNode ) ( node , next )
5985 expect ( renderString ) . toEqual ( '<h1>text</h1>' )
0 commit comments