{
- "outputPath": "dist/piggybank",
+ "outputPath": "functions/dist/piggybank",
- "outputPath": "dist/piggybank-server",
+ "outputPath:": "functions/dist/piggybank-server",
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { HttpInterceptor, HttpEvent, HttpRequest, HttpHandler } from '@angular/common/http'; | |
| import { Observable } from 'rxjs/Observable'; | |
| export class LoadingInterceptor implements HttpInterceptor { | |
| intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | |
| const loadingReq = req.clone({ | |
| reportProgress: true | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| afterEach(() => { | |
| httpMock.verify(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('should return an Observable<SearchResults>', () => { | |
| service.search('users', dummyParams) | |
| .subscribe(result => { | |
| expect(result.items.length).toBe(2); | |
| }); | |
| const req = httpMock.expectOne(`${service.API_URL}/search/users?q=cironunes`); | |
| expect(req.request.url).toBe(`${service.API_URL}/search/users`); | |
| expect(req.request.params).toEqual(dummyParams); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('#search', () => { | |
| const dummyParams = new HttpParams().set('q', 'cironunes'); | |
| it('should throw an error if trying to search for not supported `what`', () => { | |
| service.search('unknown', dummyParams) | |
| .subscribe(() => {}, err => { | |
| expect(err).toBe(`Searching for unknown is not supported. The available types are: ${service.WHAT.join(', ')}.`); | |
| }); | |
| httpMock.expectNone(`${service.API_URL}/search/users?q=cironunes`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('#getUsers', () => { | |
| it('should return an Observable<User[]>', () => { | |
| const dummyUsers = [ | |
| { login: 'John' }, | |
| { login: 'Doe' } | |
| ]; | |
| service.getUsers().subscribe(users => { | |
| expect(users.length).toBe(2); | |
| expect(users).toEqual(dummyUsers); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injectable } from '@angular/core'; | |
| import { HttpClient, HttpParams } from '@angular/common/http'; | |
| import { Observable } from 'rxjs/Observable'; | |
| import 'rxjs/add/observable/throw'; | |
| export interface User { | |
| login: string; | |
| } | |
| export interface Issue {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { TestBed, getTestBed } from '@angular/core/testing'; | |
| import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; | |
| import { GithubApiService } from './github-api.service'; | |
| describe('GithubApiService', () => { | |
| let injector: TestBed; | |
| let service: GithubApiService; | |
| let httpMock: HttpTestingController; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Http | |
| this.users = this.http.get('https://api.github.com/users') | |
| .map(response => response.json()) | |
| .subscribe(data => console.log(data)); |
NewerOlder