Let's add Redux to our project, in order to test it. You already know how to add JavaScript dependencies as follows:
yarn add react-redux--exact
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 = { name: "Dr. Yoshmi Mukhiya", email: "[email protected]", age: 22 ...