@@ -2,7 +2,7 @@ import { DebugElement } from '@angular/core';
22import { fakeAsync , TestBed , tick , flush , waitForAsync , ComponentFixture } from '@angular/core/testing' ;
33import { By } from '@angular/platform-browser' ;
44import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
5- import { IgxTooltipSingleTargetComponent , IgxTooltipMultipleTargetsComponent , IgxTooltipPlainStringComponent , IgxTooltipWithToggleActionComponent } from '../../test-utils/tooltip-components.spec' ;
5+ import { IgxTooltipSingleTargetComponent , IgxTooltipMultipleTargetsComponent , IgxTooltipPlainStringComponent , IgxTooltipWithToggleActionComponent , IgxTooltipMultipleTooltipsComponent } from '../../test-utils/tooltip-components.spec' ;
66import { UIInteractions } from '../../test-utils/ui-interactions.spec' ;
77import { HorizontalAlignment , VerticalAlignment , AutoPositionStrategy } from '../../services/public_api' ;
88import { IgxTooltipDirective } from './tooltip.directive' ;
@@ -621,6 +621,36 @@ describe('IgxTooltip', () => {
621621 } ) ) ;
622622 } ) ;
623623
624+ describe ( 'Multiple tooltips' , ( ) => {
625+ let targetOne : IgxTooltipTargetDirective ;
626+
627+ let tooltipOne : IgxTooltipDirective ;
628+ let tooltipTwo : IgxTooltipDirective ;
629+
630+ beforeEach ( waitForAsync ( ( ) => {
631+ fix = TestBed . createComponent ( IgxTooltipMultipleTooltipsComponent ) ;
632+ fix . detectChanges ( ) ;
633+ targetOne = fix . componentInstance . targetOne ;
634+ tooltipOne = fix . componentInstance . tooltipOne ;
635+ tooltipTwo = fix . componentInstance . tooltipTwo ;
636+ } ) ) ;
637+
638+ it ( 'should not add multiple document:touchstart event listeners when having multiple igxTooltip instances - #16100' , fakeAsync ( ( ) => {
639+ spyOn < any > ( tooltipOne , 'onDocumentTouchStart' ) . and . callThrough ( ) ;
640+ spyOn < any > ( tooltipTwo , 'onDocumentTouchStart' ) . and . callThrough ( ) ;
641+
642+ touchElement ( targetOne ) ;
643+ tick ( 500 ) ;
644+
645+ const dummyDiv = fix . debugElement . query ( By . css ( '.dummyDiv' ) ) ;
646+ touchElement ( dummyDiv ) ;
647+ flush ( ) ;
648+
649+ expect ( tooltipOne [ 'onDocumentTouchStart' ] ) . toHaveBeenCalledTimes ( 1 ) ;
650+ expect ( tooltipTwo [ 'onDocumentTouchStart' ] ) . not . toHaveBeenCalled ( ) ;
651+ } ) ) ;
652+ } ) ;
653+
624654 describe ( 'Tooltip integration' , ( ) => {
625655 beforeEach ( waitForAsync ( ( ) => {
626656 fix = TestBed . createComponent ( IgxTooltipWithToggleActionComponent ) ;
0 commit comments