Skip to content

Commit

Permalink
test(tooltip): add close on escape key test #1710
Browse files Browse the repository at this point in the history
  • Loading branch information
Tacho committed Sep 17, 2018
1 parent 669a4ee commit 5077484
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,19 @@ describe('IgxTooltip', () => {
verifyTooltipVisibility(fix, tooltipNativeElement, false);
}));

it('IgxTooltip closes on pressing \'escape\' key', fakeAsync(() => {
tooltipTarget.openTooltip();
flush();
fix.detectChanges();
verifyTooltipVisibility(fix, tooltipNativeElement, true);

UIInteractions.simulateKeyDownEvent(document.documentElement, 'Escape');

flush();
fix.detectChanges();
verifyTooltipVisibility(fix, tooltipNativeElement, false);
}));

describe('Tooltip events', () => {
it('should emit the proper events when hovering/unhovering target', fakeAsync(() => {
spyOn(tooltipTarget.onTooltipOpening, 'emit');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class IgxTooltipTargetDirective extends IgxToggleActionDirective implemen

/* Public Methods */
@HostListener('document:keydown.escape', ['$event'])
public onKeydownEscape(event: KeyboardEvent) {
public onKeydownEscape(event: KeyboardEvent) {
const args = { tooltip: this.target, cancel: false };
this.onTooltipClosing.emit(args);

Expand Down

0 comments on commit 5077484

Please sign in to comment.