Skip to content

Commit bb9ca69

Browse files
committed
test(tooltip): should not call hideTooltip multiple times on document:touchstart
1 parent 0c0f3cc commit bb9ca69

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

projects/igniteui-angular/src/lib/directives/tooltip/tooltip.directive.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ describe('IgxTooltip', () => {
273273
flush();
274274

275275
verifyTooltipVisibility(tooltipNativeElement, tooltipTarget, true);
276-
276+
277277
fix.componentInstance.showButton = false;
278278
fix.detectChanges();
279279
flush();
@@ -560,6 +560,20 @@ describe('IgxTooltip', () => {
560560
// Tooltip is NOT visible and positioned relative to buttonOne
561561
verifyTooltipPosition(tooltipNativeElement, buttonOne, false);
562562
}));
563+
564+
it('Should not call `hideTooltip` multiple times on document:touchstart', fakeAsync(() => {
565+
spyOn(targetOne, 'hideTooltip').and.callThrough();
566+
spyOn(targetTwo, 'hideTooltip').and.callThrough();
567+
568+
touchElement(buttonOne);
569+
tick(500);
570+
571+
const dummyDiv = fix.debugElement.query(By.css('.dummyDiv'));
572+
touchElement(dummyDiv);
573+
574+
expect(targetOne.hideTooltip).not.toHaveBeenCalled();
575+
expect(targetTwo.hideTooltip).toHaveBeenCalledTimes(1);
576+
}));
563577
});
564578

565579
describe('Tooltip integration', () => {

projects/igniteui-angular/src/lib/test-utils/tooltip-components.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IgxToggleActionDirective, IgxToggleDirective } from '../directives/togg
66
@Component({
77
template: `
88
<div class="dummyDiv">dummy div for touch tests</div>
9-
9+
1010
@if (showButton) {
1111
<button [igxTooltipTarget]="tooltipRef" [tooltip]="'Infragistics Inc. HQ'"
1212
(tooltipShow)="showing($event)" (tooltipHide)="hiding($event)"
@@ -42,6 +42,8 @@ export class IgxTooltipSingleTargetComponent {
4242

4343
@Component({
4444
template: `
45+
<div class="dummyDiv">dummy div for touch tests</div>
46+
4547
<button class="buttonOne" #targetOne="tooltipTarget" [igxTooltipTarget]="tooltipRef" style="margin: 100px">
4648
Target One
4749
</button>

0 commit comments

Comments
 (0)