Fixed automatically generated unit-tests
[examples/angular-tour-of-heroes] / src / app / heroes / heroes.component.spec.ts
index 66518e4..49cddf7 100644 (file)
@@ -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<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();
   }));