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:
@ -31,7 +31,7 @@ assert(decAction().type === DECREMENT);
|
||||
The Redux store should initialize with a `state` of 0.
|
||||
|
||||
```js
|
||||
assert(store.getState() === 0);
|
||||
assert(_store.getState() === 0);
|
||||
```
|
||||
|
||||
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
|
||||
assert(
|
||||
(function () {
|
||||
const initialState = store.getState();
|
||||
store.dispatch(incAction());
|
||||
const incState = store.getState();
|
||||
const initialState = _store.getState();
|
||||
_store.dispatch(incAction());
|
||||
const incState = _store.getState();
|
||||
return initialState + 1 === incState;
|
||||
})()
|
||||
);
|
||||
@ -52,9 +52,9 @@ Dispatching `decAction` on the Redux store should decrement the `state` by 1.
|
||||
```js
|
||||
assert(
|
||||
(function () {
|
||||
const initialState = store.getState();
|
||||
store.dispatch(decAction());
|
||||
const decState = store.getState();
|
||||
const initialState = _store.getState();
|
||||
_store.dispatch(decAction());
|
||||
const decState = _store.getState();
|
||||
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
|
||||
```
|
||||
|
||||
## --after-user-code--
|
||||
|
||||
```js
|
||||
const _store = Redux.createStore(counterReducer)
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
||||
```js
|
||||
|
Reference in New Issue
Block a user