Last active
November 30, 2019 01:43
-
-
Save nicolasmendonca/565e58384c8e4e70e3424e13b108cfff to your computer and use it in GitHub Desktop.
This file contains 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
{ | |
"singleQuote": true, | |
"useTabs": true, | |
"tabWidth": 2, | |
"trailingComma": "es5", | |
"endOfLine": "lf", | |
"printWidth": 80, | |
"semi": true | |
} |
This file contains 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
// __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