Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frederikprijck/7e756095b688240f72ca1c0bc5fc1e1f to your computer and use it in GitHub Desktop.
Save frederikprijck/7e756095b688240f72ca1c0bc5fc1e1f to your computer and use it in GitHub Desktop.
import {
inject,
TestBed
} from '@angular/core/testing';
import { AppComponent } from './app.container';
import { AppSandbox } from '../../core.sandbox';
import { Observable } from 'rxjs/Observable';
describe('App', () => {
beforeEach(() => TestBed.configureTestingModule({
providers: [
{ provide: AppSandbox, useValue: {
checkAuthentication: () => {},
currentUser$: Observable.of({}),
isLoading: Observable.of({})}
},
AppComponent
]}));
it('should exist', inject([ AppComponent ], (app: AppComponent) => {
expect(app).toBeTruthy();
}));
it('should call AppSandbox.checkAuthentication on init', inject([
AppComponent,
AppSandbox
], (component: AppComponent, sb: AppSandbox) => {
spyOn(sb, 'checkAuthentication').and.stub();
component.ngOnInit();
expect(sb.checkAuthentication).toHaveBeenCalled();
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment