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

100% Statements 13/13
100% Branches 0/0
100% Functions 2/2
100% Lines 10/10

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 40 41 421x 1x 1x                   1x   82x   82x               82x 82x 82x             1x                
import { Component, Inject, Input, LOCALE_ID } 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 SideBarComponent
     * @param router: Router
     * @param alert: AlertService
     * @param locale: LOCALE_ID
     */
    constructor(public router: Router,
                private readonly alert: AlertService,
                @Inject(LOCALE_ID) public locale: string) {
    }
 
    /**
     * on click search button
     */
    onClickSearch(): void {
        this.router.navigate(['/search'], { queryParams: { q: this.searchFor}})
            .catch(// istanbul ignore next
                reason => {
                    this.alert.error(reason);
                });
    }
 
}