Updating the app
We’ve completed the work on building the sagas, but we have just a couple of adjustments to make in the rest of the app.
The MenuButtons
component is already functionally complete, but we need to update the tests to properly exercise the middleware, in two ways: first, we must stub out the WebSocket constructor, and second, we need to fire off a TRY_START_WATCHING
action as soon as the app starts:
- Open
test/MenuButtons.test.js
and start by importing theact
function. We’ll need this to await our socket saga actions:import { act } from "react-dom/test-utils";
- Next, find the
describe
block namedsharing button
and insert the followingbeforeEach
block, which is similar to the same stubbed constructor you used in the saga tests:describe("sharing button", () => { let socketSpyFactory; let socketSpy; beforeEach(() => { socketSpyFactory = jest.spyOn( ...