import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DashboardComponent } from './dashboard.component';
+import { HeroService } from '../hero.service';
+import { of } from 'rxjs';
describe('DashboardComponent', () => {
let component: DashboardComponent;
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ DashboardComponent ]
+ declarations: [ DashboardComponent ],
+ providers: [
+ { provide: HeroService, useValue: { getHeroes: () => of([])}}
+ ]
})
.compileComponents();
}));
import { TestScheduler } from 'rxjs/testing';
import { HeroService } from './hero.service';
-import { Hero } from './hero';
-import {map} from 'rxjs/operators';
+import { HttpClientTestingModule } from '@angular/common/http/testing';
describe('HeroService', () => {
let service: HeroService;
let scheduler: TestScheduler;
beforeEach(() => {
- TestBed.configureTestingModule({});
+ TestBed.configureTestingModule({
+ imports: [ HttpClientTestingModule ]
+ });
service = TestBed.inject(HeroService);
scheduler = new TestScheduler(((actual, expected) => {
expect(actual).toEqual(expected);