1 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 import { HeroDetailComponent } from './hero-detail.component';
5 import { Observable, of } from 'rxjs';
6 import { Hero } from '../hero';
7 import { HeroService } from '../hero.service';
8 import {ActivatedRoute } from '@angular/router';
10 class MockHeroService {
12 getHero(id: number): Observable<Hero> {
13 return of({ id: 666, name: 'Mister Devil' });
19 describe('HeroDetailComponent', () => {
20 let component: HeroDetailComponent;
21 let fixture: ComponentFixture<HeroDetailComponent>;
23 beforeEach(async(() => {
24 TestBed.configureTestingModule({
25 declarations: [ HeroDetailComponent ],
27 { provide: ActivatedRoute, useValue: {
28 params: of({ id: '666'})
31 { provide: HeroService, useClass: MockHeroService },
32 { provide: Location, useClass: MockLocation }
39 fixture = TestBed.createComponent(HeroDetailComponent);
40 component = fixture.componentInstance;
41 fixture.detectChanges();
44 it('should create', () => {
45 expect(component).toBeTruthy();