Created
October 10, 2018 15:30
-
-
Save LayZeeDK/f5f80fa60e317a733d845d316c8e0fbd to your computer and use it in GitHub Desktop.
Heroes: Observing the heroes$ property of the container component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fakeAsync, tick } from '@angular/core/testing'; | |
import { Subject } from 'rxjs'; | |
import { takeUntil } from 'rxjs/operators'; | |
import { HeroService } from '../hero.service'; | |
import { HeroesContainerComponent } from './heroes.container'; | |
describe(HeroesContainerComponent.name, () => { | |
let container: HeroesContainerComponent; | |
const destroy: Subject<void> = new Subject(); | |
const heroServiceStub: jasmine.SpyObj<HeroService> = createHeroServiceStub(); | |
const observer: jasmine.Spy = jasmine.createSpy('heroes observer'); | |
beforeEach(fakeAsync(() => { | |
container = new HeroesContainerComponent(heroServiceStub); | |
container.heroes$.pipe(takeUntil(destroy)).subscribe(observer); | |
tick(); | |
})); | |
afterEach(() => { | |
destroy.next(); | |
observer.calls.reset(); | |
resetHeroServiceStub(heroServiceStub); | |
}); | |
afterAll(() => { | |
destroy.complete(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment