Exercises
The following are some exercises for you to try out:
- Complete the message property tests on the
toBeRenderedWithPropsmatcher. - Add the
toBeFirstRenderedWithPropsmatcher and update your test suite to use this matcher. Since this matcher is very similar totoBeRenderedWithProps, you can add it to the same module file that contains thetoBeRenderedWithPropsmatcher. You can also try to factor out any shared code into its own function that both matchers can use. - Add a
toBeRenderedmatcher that checks if a component was rendered without checking its props. - Complete the matchers you’ve written so that they throw an exception if the passed argument is not a Jest mock.
- Create a new component,
AppointmentFormLoader, that calls theGET /availableTimeSlotsendpoint when mounted. It should render anAppointmentFormcomponent with itsappointmentsprop set to the data returned from the server.