11import React from 'react' ;
2- import { mount , useComponent } from '../../utils/mount' ;
2+ import { ref } from 'vue' ;
3+ import type { Ref } from 'vue' ;
4+ import { Wrapper , mount , useComponent } from '../../utils/mount' ;
35import SfTooltipObject from './SfTooltip.PageObject' ;
46
57const { vue : SfTooltipVue , react : SfTooltipReact } = useComponent ( 'SfTooltip' ) ;
@@ -13,25 +15,47 @@ describe('SfTooltip', () => {
1315 children ?: string | React . ReactElement ;
1416 className ?: string ;
1517 showArrow ?: boolean ;
18+ id ?: string ;
19+ 'data-testid' ?: string ;
20+ modelValue ?: Ref < boolean > ;
1621 } = { } ,
1722 ) => {
18- const { label = 'Tooltip text' , children = 'Content' , showArrow = false , className } = props ;
23+ const {
24+ label = 'Tooltip text' ,
25+ children = 'Content' ,
26+ showArrow = false ,
27+ className,
28+ id,
29+ 'data-testid' : dataTestid ,
30+ modelValue,
31+ } = props ;
1932 return mount ( {
2033 vue : {
2134 component : SfTooltipVue ,
2235 props : {
2336 label,
2437 class : className ,
2538 showArrow,
39+ modelValue,
40+ id,
41+ dataTestid,
2642 } ,
2743 slots : {
2844 default : children ,
2945 } ,
3046 } ,
3147 react : (
32- < SfTooltipReact label = { label } className = { className } showArrow = { showArrow } >
48+ < Wrapper
49+ component = { SfTooltipReact }
50+ open = { modelValue }
51+ label = { label }
52+ className = { className }
53+ showArrow = { showArrow }
54+ id = { id }
55+ data-testid = { dataTestid }
56+ >
3357 { children }
34- </ SfTooltipReact >
58+ </ Wrapper >
3559 ) ,
3660 } ) ;
3761 } ;
@@ -84,4 +108,30 @@ describe('SfTooltip', () => {
84108 page ( ) . hasClass ( props . className ) ;
85109 } ) ;
86110 } ) ;
111+
112+ describe ( 'When id prop is added' , ( ) => {
113+ it ( 'Should apply given id to tooltip element' , ( ) => {
114+ const props = { id : 'custom-id' } ;
115+ initializeComponent ( props ) ;
116+
117+ page ( ) . hasTooltipId ( props . id ) ;
118+ } ) ;
119+ } ) ;
120+
121+ describe ( 'When open modelValue changes' , ( ) => {
122+ it ( 'Should react to the changes' , ( ) => {
123+ const modelValue = ref ( false ) ;
124+ initializeComponent ( { modelValue } ) ;
125+
126+ page ( ) . isTooltipHidden ( ) ;
127+
128+ cy . then ( ( ) => {
129+ modelValue . value = true ;
130+ page ( ) . isTooltipVisible ( ) ;
131+ } ) . then ( ( ) => {
132+ modelValue . value = false ;
133+ page ( ) . isTooltipHidden ( ) ;
134+ } ) ;
135+ } ) ;
136+ } ) ;
87137} ) ;
0 commit comments