1 import { TestBed} from '@angular/core/testing';
2 import { TestScheduler } from 'rxjs/testing';
4 import { HeroService } from './hero.service';
5 import { Hero } from './hero';
6 import {map} from 'rxjs/operators';
8 describe('HeroService', () => {
9 let service: HeroService;
10 let scheduler: TestScheduler;
13 TestBed.configureTestingModule({});
14 service = TestBed.inject(HeroService);
15 scheduler = new TestScheduler(((actual, expected) => {
16 expect(actual).toEqual(expected);
20 it('should be created', () => {
21 expect(service).toBeTruthy();
24 it('get for id=0 should return an empty Observable', () =>
25 scheduler.run(({expectObservable}) => {
26 expectObservable(service.getHero(0)).toBe('(|)');
30 it('get for id=11 should return an Observable, that contains the hero with id 11', () =>
31 scheduler.run(({expectObservable}) => {
32 expectObservable(service.getHero(11)).toBe('(a|)', { a: { id: 11, name: 'Dr Nice' }});