X-Git-Url: http://juplo.de/gitweb/?p=examples%2Fangular-tour-of-heroes;a=blobdiff_plain;f=src%2Fapp%2Fheroes%2Fheroes.component.spec.ts;h=49cddf76c51d8383b3441a09d5f38ba052e54f66;hp=66518e44b77fb16004cbb00aeed9c2f60ea00979;hb=85f4c0710394f70f840038f5b3185e3adb8981e4;hpb=ce854cde799ab563bb176431cc94fe686cbb24e4 diff --git a/src/app/heroes/heroes.component.spec.ts b/src/app/heroes/heroes.component.spec.ts index 66518e4..49cddf7 100644 --- a/src/app/heroes/heroes.component.spec.ts +++ b/src/app/heroes/heroes.component.spec.ts @@ -2,13 +2,31 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { HeroesComponent } from './heroes.component'; +import { Observable, of } from 'rxjs'; +import { Hero } from '../hero'; +import { HEROES } from '../mock-heroes'; +import { HeroService } from '../hero.service'; +import { MessageService } from '../message.service'; + +class MockHeroService { + getHeroes() : Observable { + return of(HEROES); + } +} + +class MockMessageService {} + describe('HeroesComponent', () => { let component: HeroesComponent; let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ HeroesComponent ] + declarations: [ HeroesComponent ], + providers: [ + { provide: HeroService, useClass: MockHeroService }, + { provide: MessageService, useClass: MockMessageService } + ] }) .compileComponents(); }));