Manipulating State of Stateful Component in Tests
Let’s learn how to manipulate states of a stateful component through Enzyme's method in tests.
We'll cover the following...
We'll cover the following...
Manipulating state in tests
So far, the carousel is just a pair of buttons. What it really needs is some slides. A simple approach to this is to give the Carousel instance an array of data as a prop called slides, then pass the data from slides[slideIndex] as props to a CarouselSlide.
- Replace the existing
beforeEachblock to set theslidesprop on theCarouselinstance, then add a (failing) test for the slide-passing behavior:
...
- The new test uses a method called
props()instead ofprop(). This method returns an object containing all of the