@@ -91,6 +91,54 @@ describe("TooltipTriggerComponent", () => {
9191 hostEl . dispatchEvent ( new Event ( "mouseenter" ) ) ;
9292 expect ( tooltip . showTooltip ) . not . toHaveBeenCalled ( ) ;
9393 } ) ;
94+
95+ it ( "should not call showTooltip after recent touchstart" , ( ) => {
96+ tooltip . openWith = jest . fn ( ( ) => "both" ) ;
97+
98+ hostEl . dispatchEvent ( new Event ( "touchstart" ) ) ;
99+ hostEl . dispatchEvent ( new Event ( "mouseenter" ) ) ;
100+
101+ expect ( tooltip . showTooltip ) . not . toHaveBeenCalled ( ) ;
102+ } ) ;
103+ } ) ;
104+
105+ describe ( "touch interaction" , ( ) => {
106+ it ( "should toggle tooltip on touchend regardless of openWith" , ( ) => {
107+ tooltip . openWith = jest . fn ( ( ) => "hover" ) ;
108+
109+ hostEl . dispatchEvent ( new Event ( "touchstart" ) ) ;
110+ hostEl . dispatchEvent ( new Event ( "touchend" ) ) ;
111+
112+ expect ( tooltip . toggleTooltip ) . toHaveBeenCalledTimes ( 1 ) ;
113+ } ) ;
114+
115+ it ( "should not double-toggle on touch (click is ignored)" , ( ) => {
116+ tooltip . openWith = jest . fn ( ( ) => "both" ) ;
117+
118+ hostEl . dispatchEvent ( new Event ( "touchstart" ) ) ;
119+ hostEl . dispatchEvent ( new Event ( "mouseenter" ) ) ;
120+ hostEl . dispatchEvent ( new Event ( "focusin" ) ) ;
121+ hostEl . dispatchEvent ( new Event ( "touchend" ) ) ;
122+ hostEl . click ( ) ;
123+
124+ expect ( tooltip . showTooltip ) . not . toHaveBeenCalled ( ) ;
125+ expect ( tooltip . toggleTooltip ) . toHaveBeenCalledTimes ( 1 ) ;
126+ } ) ;
127+
128+ it ( "should reset isTouch flag after touchend timeout" , ( ) => {
129+ jest . useFakeTimers ( ) ;
130+ tooltip . openWith = jest . fn ( ( ) => "both" ) ;
131+
132+ hostEl . dispatchEvent ( new Event ( "touchstart" ) ) ;
133+ hostEl . dispatchEvent ( new Event ( "touchend" ) ) ;
134+
135+ jest . advanceTimersByTime ( 300 ) ;
136+
137+ hostEl . dispatchEvent ( new Event ( "mouseenter" ) ) ;
138+ expect ( tooltip . showTooltip ) . toHaveBeenCalled ( ) ;
139+
140+ jest . useRealTimers ( ) ;
141+ } ) ;
94142 } ) ;
95143
96144 describe ( "mouseleave" , ( ) => {
@@ -127,6 +175,16 @@ describe("TooltipTriggerComponent", () => {
127175 jest . advanceTimersByTime ( 100 ) ;
128176 expect ( tooltip . hideTooltip ) . not . toHaveBeenCalled ( ) ;
129177 } ) ;
178+
179+ it ( "should not call hideTooltip after recent touchstart" , ( ) => {
180+ tooltip . openWith = jest . fn ( ( ) => "both" ) ;
181+
182+ hostEl . dispatchEvent ( new Event ( "touchstart" ) ) ;
183+ hostEl . dispatchEvent ( new Event ( "mouseleave" ) ) ;
184+
185+ jest . advanceTimersByTime ( 100 ) ;
186+ expect ( tooltip . hideTooltip ) . not . toHaveBeenCalled ( ) ;
187+ } ) ;
130188 } ) ;
131189
132190 describe ( "focusin" , ( ) => {
0 commit comments