@@ -2,7 +2,7 @@ import { DebugElement } from '@angular/core';
2
2
import { fakeAsync , TestBed , tick , flush , waitForAsync , ComponentFixture } from '@angular/core/testing' ;
3
3
import { By } from '@angular/platform-browser' ;
4
4
import { 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' ;
6
6
import { UIInteractions } from '../../test-utils/ui-interactions.spec' ;
7
7
import { HorizontalAlignment , VerticalAlignment , AutoPositionStrategy } from '../../services/public_api' ;
8
8
import { IgxTooltipDirective } from './tooltip.directive' ;
@@ -621,6 +621,36 @@ describe('IgxTooltip', () => {
621
621
} ) ) ;
622
622
} ) ;
623
623
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
+
624
654
describe ( 'Tooltip integration' , ( ) => {
625
655
beforeEach ( waitForAsync ( ( ) => {
626
656
fix = TestBed . createComponent ( IgxTooltipWithToggleActionComponent ) ;
0 commit comments