Fixed automatically generated unit-tests
[examples/angular-tour-of-heroes] / src / app / heroes / heroes.component.spec.ts
1 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2
3 import { HeroesComponent } from './heroes.component';
4
5 import { Observable, of } from 'rxjs';
6 import { Hero } from '../hero';
7 import { HEROES } from '../mock-heroes';
8 import { HeroService } from '../hero.service';
9 import { MessageService } from '../message.service';
10
11 class MockHeroService {
12   getHeroes() : Observable<Hero[]> {
13     return of(HEROES);
14   }
15 }
16
17 class MockMessageService {}
18
19 describe('HeroesComponent', () => {
20   let component: HeroesComponent;
21   let fixture: ComponentFixture<HeroesComponent>;
22
23   beforeEach(async(() => {
24     TestBed.configureTestingModule({
25       declarations: [ HeroesComponent ],
26       providers: [
27         { provide: HeroService, useClass: MockHeroService },
28         { provide: MessageService, useClass: MockMessageService }
29       ]
30     })
31     .compileComponents();
32   }));
33
34   beforeEach(() => {
35     fixture = TestBed.createComponent(HeroesComponent);
36     component = fixture.componentInstance;
37     fixture.detectChanges();
38   });
39
40   it('should create', () => {
41     expect(component).toBeTruthy();
42   });
43 });