All files / src/app/widgets/search-bar search-bar.component.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 2/2
100% Lines 9/9

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 30 31 32 33 34 35 36 37 38 39 401x 1x 1x                   1x   83x   83x             83x 83x             1x                
import { Component, Input } from '@angular/core';
import { Router } from '@angular/router';
import { AlertService } from '../../services';
 
/**
 * Search Bar Component
 */
@Component({
    selector: 'app-search-bar',
    templateUrl: './search-bar.component.html',
    styleUrls: ['./search-bar.component.scss']
})
export class SearchBarComponent {
    /** css class of header */
    @Input() readonly headerCssClass = '';
    /** search for */
    searchFor = '';
 
    /**
     * constructor of SearchBarComponent
     * @param router: Router
     * @param alert: AlertService
     */
    constructor(public router: Router,
                private readonly alert: AlertService) {
    }
 
    /**
     * on click search button
     */
    onClickSearch(): void {
        this.router.navigate(['/search'], { queryParams: { q: this.searchFor}})
            .catch(// istanbul ignore next
                reason => {
                    this.alert.error(reason);
                });
    }
 
}