Skip to content

Instantly share code, notes, and snippets.

View cironunes's full-sized avatar
🎯
Focusing

Ciro Nunes cironunes

🎯
Focusing
View GitHub Profile
@cironunes
cironunes / angular.json.md
Last active February 10, 2021 03:28
Firebase Cloud Function for Angular SSR
{
-  "outputPath": "dist/piggybank", 
+  "outputPath": "functions/dist/piggybank",
-  "outputPath": "dist/piggybank-server",
+  "outputPath:": "functions/dist/piggybank-server",
}
@cironunes
cironunes / medicos.md
Last active October 20, 2017 11:40 — forked from fernandosouza/medicos_dentistas_berlin.txt
Médicos e dentistas brasileiros em berlin

Clínica geral

Marcus Thuma. Kant Praxis
Centro para medicina interna
Cardiologia, Gastroenterologia, Clínica Geral
Kurfürstendamm 42
10719 Berlim
Tel: (030) 88 71 44 60
Fax: (030) 88 71 44 619
@cironunes
cironunes / loading.interceptor.ts
Created September 6, 2017 16:16
Loading interceptor
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
});
afterEach(() => {
httpMock.verify();
});
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);
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`);
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);
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 {}
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;
@cironunes
cironunes / http-example.ts
Created August 10, 2017 16:17
Angular former Http example
// Http
this.users = this.http.get('https://api.github.com/users')
.map(response => response.json())
.subscribe(data => console.log(data));