This repository was archived by the owner on Jan 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
packages/mdc-tooltip/test Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -458,6 +458,35 @@ describe('MDCTooltip', () => {
458458 document . body . removeChild ( fixture ) ;
459459 } ) ;
460460
461+ it ( '#initialSyncWithDOM registers click event handler on the anchor element' ,
462+ ( ) => {
463+ const tooltipElem = fixture . querySelector < HTMLElement > ( '#tt0' ) ! ;
464+ const anchorElem =
465+ fixture . querySelector < HTMLElement > ( '[aria-describedby]' ) ! ;
466+ const component = MDCTooltip . attachTo ( tooltipElem ) ;
467+ const foundation = component [ 'foundation' ] ;
468+ spyOn ( foundation , 'handleAnchorClick' ) ;
469+
470+ emitEvent ( anchorElem , 'click' ) ;
471+
472+ expect ( foundation . handleAnchorClick ) . toHaveBeenCalled ( ) ;
473+ component . destroy ( ) ;
474+ } ) ;
475+
476+ it ( '#destroy deregisters click event handler on the anchor element' , ( ) => {
477+ const tooltipElem = fixture . querySelector < HTMLElement > ( '#tt0' ) ! ;
478+ const anchorElem =
479+ fixture . querySelector < HTMLElement > ( '[aria-describedby]' ) ! ;
480+ const component = MDCTooltip . attachTo ( tooltipElem ) ;
481+ const foundation = component [ 'foundation' ] ;
482+ spyOn ( foundation , 'handleAnchorClick' ) ;
483+
484+ component . destroy ( ) ;
485+ emitEvent ( anchorElem , 'click' ) ;
486+
487+ expect ( foundation . handleAnchorClick ) . not . toHaveBeenCalled ( ) ;
488+ } ) ;
489+
461490 it ( 'aria-expanded remains false on anchor when mouseenter anchor' , ( ) => {
462491 const tooltipElem = fixture . querySelector < HTMLElement > ( '#tt0' ) ! ;
463492 const anchorElem =
You can’t perform that action at this time.
0 commit comments