All files / app/directive fake-link.directive.ts

100% Statements 11/11
100% Branches 7/7
100% Functions 6/6
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30102x                 214x   69x       1x         1x         1x        
import { Directive, ElementRef, HostListener } from '@angular/core';
 
@Directive({
  selector: '.fake-link',
  host: {
    role: 'button',
    tabindex: '0',
  },
})
export class FakeLinkDirective {
 
  constructor(private elementRef: ElementRef<HTMLElement>) { }
 
  @HostListener('keydown.enter')
  activateWithEnter(): void {
    this.elementRef.nativeElement.click();
  }
 
  @HostListener('keydown.space', ['$event'])
  preventSpaceScroll(event: Event): void {
    event.preventDefault();
  }
 
  @HostListener('keyup.space')
  activateWithSpace(): void {
    this.elementRef.nativeElement.click();
  }
 
}