Skip to content
Snippets Groups Projects
Commit 562f09a3 authored by Art Lowel's avatar Art Lowel
Browse files

turned null actions in to classes

parent 5e523a56
No related merge requests found
......@@ -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);
......
......@@ -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);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment