import { NO_ERRORS_SCHEMA } from '@angular/core'; import { inject, async, TestBed, ComponentFixture } from '@angular/core/testing'; /** * Load the implementations that should be tested */ import { AppComponent } from './app.component'; import { AppState } from './app.service'; describe(`App`, () => { let comp: AppComponent; let fixture: ComponentFixture; /** * async beforeEach */ beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ AppComponent ], schemas: [NO_ERRORS_SCHEMA], providers: [AppState] }) /** * Compile template and css */ .compileComponents(); })); /** * Synchronous beforeEach */ beforeEach(() => { fixture = TestBed.createComponent(AppComponent); comp = fixture.componentInstance; /** * Trigger initial data binding */ fixture.detectChanges(); }); it(`should be readly initialized`, () => { expect(fixture).toBeDefined(); expect(comp).toBeDefined(); }); it(`should be @AngularClass`, () => { expect(comp.url).toEqual('https://twitter.com/AngularClass'); expect(comp.angularclassLogo).toEqual('assets/img/angularclass-avatar.png'); expect(comp.name).toEqual('Angular 2 Webpack Starter'); }); it('should log ngOnInit', () => { spyOn(console, 'log'); expect(console.log).not.toHaveBeenCalled(); comp.ngOnInit(); expect(console.log).toHaveBeenCalled(); }); });