@@ -614,41 +614,54 @@ describe("Tour", () => {
614
614
} ) ;
615
615
616
616
describe ( "tooltipRenderAsHtml" , ( ) => {
617
+ beforeEach ( ( ) => {
618
+ document . body . innerHTML = "" ; // Clear previous test DOM
619
+ } ) ;
617
620
test ( "should render HTML when tooltipRenderAsHtml is true" , async ( ) => {
618
621
const tour = new Tour ( ) ;
619
622
620
623
// Arrange & Act
621
- await tour
622
- . setOptions ( {
623
- tooltipRenderAsHtml : true ,
624
- } )
625
- . start ( ) ;
624
+ tour . setOptions ( {
625
+ tooltipRenderAsHtml : true ,
626
+ steps : [
627
+ {
628
+ intro : "<b>Bold text</b> and <i>italic text</i>" ,
629
+ } ,
630
+ ] ,
631
+ } ) ;
626
632
627
- tooltipText ( ) . innerHTML = "<b>Bold text</b> and <i>italic text</i>" ;
633
+ await tour . start ( ) ;
628
634
629
635
// Assert
630
- expect ( content ( tooltipText ( ) ) ) . toBe (
631
- "<b>Bold text</b> and <i>italic text</i>"
632
- ) ;
633
- expect ( tooltipText ( ) . querySelector ( "b" ) ?. textContent ) . toBe ( "Bold text" ) ;
634
- expect ( tooltipText ( ) . querySelector ( "i" ) ?. textContent ) . toBe ( "italic text" ) ;
636
+ const tooltip = find ( ".introjs-tooltiptext" ) ;
637
+ expect ( tooltip ) . not . toBeNull ( ) ;
638
+ expect ( tooltip ?. querySelector ( "b" ) ?. textContent ) . toBe ( "Bold text" ) ;
639
+ expect ( tooltip ?. querySelector ( "i" ) ?. textContent ) . toBe ( "italic text" ) ;
635
640
} ) ;
641
+
636
642
test ( "should not render HTML when tooltipRenderAsHtml is false" , async ( ) => {
637
643
const tour = new Tour ( ) ;
638
644
639
645
// Arrange & Act
640
- await tour
641
- . setOptions ( {
642
- tooltipRenderAsHtml : false ,
643
- } )
644
- . start ( ) ;
646
+ tour . setOptions ( {
647
+ tooltipRenderAsHtml : false ,
648
+ steps : [
649
+ {
650
+ intro : "<b>Bold text</b> and <i>italic text</i>" ,
651
+ } ,
652
+ ] ,
653
+ } ) ;
645
654
646
- tooltipText ( ) . innerHTML = "<b>Bold text</b> and <i>italic text</i>" ;
655
+ await tour . start ( ) ;
647
656
648
657
// Assert
649
- expect ( content ( tooltipText ( ) ) ) . toBe (
650
- "<b>Bold text</b> and <i>italic text</i>"
658
+ const tooltip = find ( ".introjs-tooltiptext" ) ;
659
+ expect ( tooltip ) . not . toBeNull ( ) ;
660
+ expect ( tooltip ?. innerHTML ) . toContain (
661
+ "<b>Bold text</b> and <i>italic text</i>"
651
662
) ;
663
+ expect ( tooltip ?. querySelector ( "b" ) ) . toBeNull ( ) ;
664
+ expect ( tooltip ?. querySelector ( "i" ) ) . toBeNull ( ) ;
652
665
} ) ;
653
666
} ) ;
654
667
} ) ;
0 commit comments