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.jsand start by importing theactfunction. We’ll need this to await our socket saga actions:import { act } from "react-dom/test-utils"; - Next, find the
describeblock namedsharing buttonand insert the followingbeforeEachblock, 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( Â ...