When using Redux, it can be useful to test that your initial state is being rendered as expected. In this lesson, we will set up a test to check the initial state of our store.
First, I'm going to import my Redux store. Next, I'll import my assertion library. Next, let's create our describe block, and we're going to describe the store because that's what we're testing. We'll give that a callback function. Next, let's create our It block, and say that, "It should initialize."
Now let's set up our assertion. We're going to expect that our actual value is going to equal our expected value, and now our actual value is going to be the initial state of our store. To get that, we say, "store.getState." Since we haven't dispatched anything before we're calling this, it's going to give us our initial state of our store.
Now our expected value is going to be an object, which is what Redux returns. Inside of that object, we're going to expect to have a quotes array, which will start out as empty. We're also going to have a theme object, which has a color, which we're going to expect, by default, to be my favorite color here, which is 5DC4C6.
I'm going to go up on line nine, and remove this empty space here. Now, to review what we've done, we've set up this test where we get our initial state tree. Then we set up our expected state tree, and then we are testing that our actual state tree and our expected state tree are equal.
That's how you can test your initial state tree in Redux.