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 action creator

Actually, that's quite simple with action creators because they are pure functions. We pass in an input according to the function interface and verify the output:

./js/Actions/index.spec.js

import { createStore } from "redux"; import { toggleRecording } from "./index";   describe( "Action creators", () => {   describe( "toggleRecording", () => {     it( "should return a valid action", () => {       const FLAG = true,             action = toggleRecording( FLAG );             expect( action.payload ).toEqual( { toggle: FLAG } );     });   }); }); 

We have written a test for the toggleRecording function. We assert the fact that the function produces an action object with { toggle: FLAG } in the payload. As mentioned in the previous chapter, any action is ...

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