Skip to content

Instantly share code, notes, and snippets.

@nicolasmendonca
Last active November 30, 2019 01:43
Show Gist options
  • Save nicolasmendonca/565e58384c8e4e70e3424e13b108cfff to your computer and use it in GitHub Desktop.
Save nicolasmendonca/565e58384c8e4e70e3424e13b108cfff to your computer and use it in GitHub Desktop.
{
"singleQuote": true,
"useTabs": true,
"tabWidth": 2,
"trailingComma": "es5",
"endOfLine": "lf",
"printWidth": 80,
"semi": true
}
// __stubs__/index.ts
import { of } from 'rxjs';
export const angularFireDatabaseStub = {
object: () => ( {
update: () => {}
} )
};
export const angularFireAuthStub = {
auth: {
signInWithRedirect: () => {},
signOut: () => {}
}
};
export const authServiceStub = {
user$: of( 'Reggie' ),
}
// app.component.spec.ts
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { TopNavbarComponent } from './components/shared/top-navbar/top-navbar.component';
import { SideNavbarComponent } from './components/shared/side-navbar/side-navbar.component';
import { RouterTestingModule } from "@angular/router/testing";
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { AngularFireDatabase } from 'angularfire2/database';
import { AngularFireAuth } from 'angularfire2/auth';
import { AuthService } from './services/auth.service';
import { angularFireAuthStub, angularFireDatabaseStub, authServiceStub } from './services/__stubs__';
fdescribe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports:[
RouterTestingModule,
HttpClientTestingModule
],
declarations: [
AppComponent,
TopNavbarComponent,
SideNavbarComponent
],
providers: [
{ provide: AngularFireAuth, useValue: angularFireAuthStub },
{ provide: AngularFireDatabase, useValue: angularFireDatabaseStub },
{ provide: AuthService, useValue: authServiceStub },
]
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment