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<Hero[]> {
+ return of(HEROES);
+ }
+}
+
+class MockMessageService {}
+
describe('HeroesComponent', () => {
let component: HeroesComponent;
let fixture: ComponentFixture<HeroesComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ HeroesComponent ]
+ declarations: [ HeroesComponent ],
+ providers: [
+ { provide: HeroService, useClass: MockHeroService },
+ { provide: MessageService, useClass: MockMessageService }
+ ]
})
.compileComponents();
}));