added tests for hostReducer and Header Effects, and switch to typed actions

This commit is contained in:
Art Lowel
2017-01-13 11:25:07 +01:00
parent dba6dcec63
commit 8e4bec9c30
13 changed files with 211 additions and 82 deletions

View File

@@ -0,0 +1,53 @@
import { TestBed, inject } from "@angular/core/testing";
import { EffectsTestingModule, EffectsRunner } from '@ngrx/effects/testing';
import { HeaderEffects } from "./header.effects";
import { HeaderCollapseAction } from "./header.actions";
import { HostWindowResizeAction } from "../shared/host-window.actions";
import { routerActions } from "@ngrx/router-store";
describe('HeaderEffects', () => {
beforeEach(() => TestBed.configureTestingModule({
imports: [
EffectsTestingModule
],
providers: [
HeaderEffects
]
}));
let runner: EffectsRunner;
let headerEffects: HeaderEffects;
beforeEach(inject([
EffectsRunner, HeaderEffects
],
(_runner, _headerEffects) => {
runner = _runner;
headerEffects = _headerEffects;
}
));
describe('resize$', () => {
it('should return a COLLAPSE action in response to a RESIZE action', () => {
runner.queue(new HostWindowResizeAction(800,600));
headerEffects.resize$.subscribe(result => {
expect(result).toEqual(new HeaderCollapseAction());
});
});
});
describe('routeChange$', () => {
it('should return a COLLAPSE action in response to an UPDATE_LOCATION action', () => {
runner.queue({ type: routerActions.UPDATE_LOCATION });
headerEffects.resize$.subscribe(result => {
expect(result).toEqual(new HeaderCollapseAction());
});
});
});
});