O'Reilly logo

Cross-platform Desktop Application Development: Electron, Node, NW.js, and React by Dmitry Sheiko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing reducers

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required