Skip to content

Commit e3f4716

Browse files
committed
test(tooltip): add test for close button removal when sticky is false
1 parent dfad459 commit e3f4716

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,27 @@ describe('IgxTooltip', () => {
11341134
verifyTooltipVisibility(tooltipNativeElement, tooltipTarget, true);
11351135
expect(tooltipNativeElement.getAttribute('role')).toBe('status');
11361136
});
1137+
1138+
it('should correctly remove the close button and update the role when sticky is set to false', async () => {
1139+
tooltipTarget.sticky = true;
1140+
fix.detectChanges();
1141+
hoverElement(button);
1142+
await wait(SHOW_DELAY + 50);
1143+
fix.detectChanges();
1144+
1145+
const closeBtn = tooltipNativeElement.querySelector('igx-tooltip-close-button');
1146+
expect(closeBtn).not.toBeNull();
1147+
expect(fix.componentInstance.tooltip.role).toBe('status');
1148+
1149+
tooltipTarget.sticky = false;
1150+
fix.detectChanges();
1151+
hoverElement(button);
1152+
await wait(SHOW_DELAY + 50);
1153+
fix.detectChanges();
1154+
1155+
expect(fix.componentInstance.tooltip.role).toBe('tooltip');
1156+
expect(tooltipNativeElement.querySelector('igx-tooltip-close-button')).toBeNull();
1157+
});
11371158
});
11381159
});
11391160

@@ -1222,7 +1243,7 @@ const alignmentTolerance = 2;
12221243
export const verifyTooltipPosition = (
12231244
tooltipNativeElement: HTMLElement,
12241245
actualTarget: { nativeElement: HTMLElement },
1225-
shouldAlign:boolean = true,
1246+
shouldAlign: boolean = true,
12261247
placement: Placement = Placement.Bottom,
12271248
offset: number = 6
12281249
) => {

0 commit comments

Comments
 (0)