February 2019
Intermediate to advanced
204 pages
4h 52m
English
Action creators are pretty easy to test. We already explored what action creators are and how to use them in Chapter 1, Understanding Redux. As a reminder, in Redux, action creators are simply functions that return plain objects. Nothing complicated, right? Let's consider an action creator from our health application. We just made a function called addNewDoctor that takes new doctor data and returns the plain object, as follows:
export function addNewDoctor(newDoctorData) { return { type: "ADD_NEW_DOCTOR", newDoctorData };}
Let's test our action creators, as follows:
import * as actions from "../actionCreators";describe("actions", () => { it("should create an action to add a doctor", () => { const newDoctorData = { ...Read now
Unlock full access