From 562f09a36656ad69e5e913309d995ea5ac02b4cc Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Tue, 17 Jan 2017 12:06:32 +0100 Subject: [PATCH] turned null actions in to classes --- src/app/header/header.reducer.spec.ts | 23 ++++++++++++++-------- src/app/shared/host-window.reducer.spec.ts | 18 ++++++++++++----- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/app/header/header.reducer.spec.ts b/src/app/header/header.reducer.spec.ts index a3f9f50021..2b8c26f523 100644 --- a/src/app/header/header.reducer.spec.ts +++ b/src/app/header/header.reducer.spec.ts @@ -7,19 +7,26 @@ import { HeaderToggleAction } from "./header.actions"; -describe("headerReducer", () => { - let nullAction = new HeaderCollapseAction(); - nullAction.type = null; +class NullAction extends HeaderCollapseAction { + type = null; + constructor() { + super(); + } +} + +describe("headerReducer", () => { it("should return the current state when no valid actions have been made", () => { const state = { navCollapsed: false }; - const newState = headerReducer(state, nullAction); + const action = new NullAction(); + const newState = headerReducer(state, action); expect(newState).toEqual(state); }); it("should start with navCollapsed = true", () => { - const initialState = headerReducer(undefined, nullAction); + const action = new NullAction(); + const initialState = headerReducer(undefined, action); // The navigation starts collapsed expect(initialState.navCollapsed).toEqual(true); @@ -33,7 +40,7 @@ describe("headerReducer", () => { expect(newState.navCollapsed).toEqual(true); }); - it("should perform the COLLAPSE action without mutating the previous state", () => { + it("should perform the COLLAPSE action without affecting the previous state", () => { const state = { navCollapsed: false }; deepFreeze(state); @@ -52,7 +59,7 @@ describe("headerReducer", () => { expect(newState.navCollapsed).toEqual(false); }); - it("should perform the EXPAND action without mutating the previous state", () => { + it("should perform the EXPAND action without affecting the previous state", () => { const state = { navCollapsed: true }; deepFreeze(state); @@ -71,7 +78,7 @@ describe("headerReducer", () => { expect(state3.navCollapsed).toEqual(true); }); - it("should perform the TOGGLE action without mutating the previous state", () => { + it("should perform the TOGGLE action without affecting the previous state", () => { const state = { navCollapsed: true }; deepFreeze(state); diff --git a/src/app/shared/host-window.reducer.spec.ts b/src/app/shared/host-window.reducer.spec.ts index d0c2e697c0..19d4f67697 100644 --- a/src/app/shared/host-window.reducer.spec.ts +++ b/src/app/shared/host-window.reducer.spec.ts @@ -2,19 +2,27 @@ import * as deepFreeze from "deep-freeze"; import { hostWindowReducer } from "./host-window.reducer"; import { HostWindowResizeAction } from "./host-window.actions"; +class NullAction extends HostWindowResizeAction { + type = null; + + constructor() { + super(0,0); + } +} + describe('hostWindowReducer', () => { - let nullAction = new HostWindowResizeAction(0, 0); - nullAction.type = null; it("should return the current state when no valid actions have been made", () => { const state = { width: 800, height: 600 }; - const newState = hostWindowReducer(state, nullAction); + const action = new NullAction(); + const newState = hostWindowReducer(state, action); expect(newState).toEqual(state); }); it("should start with width = null and height = null", () => { - const initialState = hostWindowReducer(undefined, nullAction); + const action = new NullAction(); + const initialState = hostWindowReducer(undefined, action); expect(initialState.width).toEqual(null); expect(initialState.height).toEqual(null); @@ -29,7 +37,7 @@ describe('hostWindowReducer', () => { expect(newState.height).toEqual(768); }); - it("should perform the RESIZE action without mutating the previous state", () => { + it("should perform the RESIZE action without affecting the previous state", () => { const state = { width: 800, height: 600 }; deepFreeze(state);