July 2017
Intermediate to advanced
300 pages
5h 43m
English
Reducers, as well as action creators, are pure functions. They accept the last state tree object and the dispatched action in parameters and produce a new state tree object. So, when testing a reducer, we are checking whether a given action modifies the state as intended:
./js/Reducers/index.spec.js
import { createStore } from "redux"; import { createReducer } from "redux-act"; import { TAB_SCREENSHOT, SCREENSHOT_DEFAULT_FILENAME, ANIMATION_DEFAULT_FILENAME } from "../Constants"; import { appReducer } from "./index"; describe( "appReducer", () => { it( "should return default state", () => { const DEFAULT_STATE = { isRecording: false, activeTab: TAB_SCREENSHOT, screenshotFilename: SCREENSHOT_DEFAULT_FILENAME, animationFilename: ...Read now
Unlock full access