@@ -35,7 +35,10 @@ jest.mock("cheerio", () => ({
3535 } ) ) ;
3636
3737 const $ = Object . assign ( selectorImpl , {
38- html : jest . fn ( ( ) => "<p>HTML fragment</p>" ) ,
38+ html : jest . fn (
39+ ( ) =>
40+ '<h1>This is heading</h1><p>This is paragraph</p><a href="https://example.com" target=\"_blank\"">This is a link</a>' ,
41+ ) ,
3942 } ) ;
4043
4144 return $ ;
@@ -480,7 +483,7 @@ describe("ContentStylingService", () => {
480483 it ( "should return styled callout component for html input" , async ( ) => {
481484 const mockCallout : HeadingWithTypedContent = {
482485 heading : "Heading for callout" ,
483- content : " <h1>This is heading</h1><p>This is paragraph</p>" ,
486+ content : ' <h1>This is heading</h1><p>This is paragraph</p><a href="https://example.com">This is a link</a>' ,
484487 contentType : "html" ,
485488 } ;
486489
@@ -494,6 +497,21 @@ describe("ContentStylingService", () => {
494497 expect ( htmlCallout ) . toBeVisible ( ) ;
495498 } ) ;
496499
500+ it ( "should return styled callout with target attributes on anchor tags for html input" , async ( ) => {
501+ const mockCallout : HeadingWithTypedContent = {
502+ heading : "Heading for callout" ,
503+ content : '<a href="https://example.com">This is a link</a>' ,
504+ contentType : "html" ,
505+ } ;
506+
507+ const styledCallout = styleCallout ( mockCallout ) ;
508+
509+ render ( styledCallout ?. component ) ;
510+
511+ const link = screen . getByRole ( "link" ) ;
512+ expect ( link ) . toHaveAttribute ( "target" , "_blank" ) ;
513+ } ) ;
514+
497515 it ( "should return styled callout component for string input" , async ( ) => {
498516 const mockCallout : HeadingWithTypedContent = {
499517 heading : "Heading for callout" ,
0 commit comments