fix(curriculum): error in asserting initial state of redux store (#45457)

Initialize different store variable (_store) to prevent test failures in case user tested his own store in the exercise.
This commit is contained in:
Radi Totev
2022-03-18 19:42:04 +02:00
committed by GitHub
parent aa7c58f7e5
commit 8a3cbde3df

View File

@ -31,7 +31,7 @@ assert(decAction().type === DECREMENT);
The Redux store should initialize with a `state` of 0. The Redux store should initialize with a `state` of 0.
```js ```js
assert(store.getState() === 0); assert(_store.getState() === 0);
``` ```
Dispatching `incAction` on the Redux store should increment the `state` by 1. Dispatching `incAction` on the Redux store should increment the `state` by 1.
@ -39,9 +39,9 @@ Dispatching `incAction` on the Redux store should increment the `state` by 1.
```js ```js
assert( assert(
(function () { (function () {
const initialState = store.getState(); const initialState = _store.getState();
store.dispatch(incAction()); _store.dispatch(incAction());
const incState = store.getState(); const incState = _store.getState();
return initialState + 1 === incState; return initialState + 1 === incState;
})() })()
); );
@ -52,9 +52,9 @@ Dispatching `decAction` on the Redux store should decrement the `state` by 1.
```js ```js
assert( assert(
(function () { (function () {
const initialState = store.getState(); const initialState = _store.getState();
store.dispatch(decAction()); _store.dispatch(decAction());
const decState = store.getState(); const decState = _store.getState();
return initialState - 1 === decState; return initialState - 1 === decState;
})() })()
); );
@ -83,6 +83,12 @@ const decAction = null; // Define an action creator for decrementing
const store = null; // Define the Redux store here, passing in your reducers const store = null; // Define the Redux store here, passing in your reducers
``` ```
## --after-user-code--
```js
const _store = Redux.createStore(counterReducer)
```
# --solutions-- # --solutions--
```js ```js