Kamil Chmielowski
Web / Angular
Jasmine code coverage report for cv app.
You can contact with me by email: kamilchmielowski94@gmail.com or my page.
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 | 1x 7x 7x 1x 3x | import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { catchError, map, Observable, of } from 'rxjs';
import { CurrentYearResponse } from './current-year.model';
import { environment } from '../../../environments/environment';
@Injectable({ providedIn: 'root' })
export class CurrentYearService {
constructor(private httpClient: HttpClient) {}
getCurrentYear(): Observable<number> {
return this.httpClient.get<CurrentYearResponse>(environment.worldClockAPI.url, {
headers: environment.worldClockAPI.headers
}).pipe(
catchError(() => of({ currentDateTime: new Date() })),
map(response => {
return (response?.currentDateTime ? new Date(response.currentDateTime) : new Date()).getFullYear();
}),
);
}
}
|