I dont know why this isn’t working. When I look at the console.log statements I can see I am not mutating state - but for some reason I get this error:
// running test
Dispatching an action of type ONLINE should update the property status in state to online and should NOT mutate state.
// tests completed
const defaultState = {
user: 'CamperBot',
status: 'offline',
friends: '732,982',
community: 'freeCodeCamp'
};
const immutableReducer = (state = defaultState, action) => {
const newObj = Object.assign({}, state);
switch(action.type) {
case 'ONLINE':
// don't mutate state here or the tests will fail
newObj.status = action.type;
console.log(defaultState, newObj)
return newObj;
default:
return state;
}
};
const wakeUp = () => {
return {
type: 'ONLINE'
}
};
const store = Redux.createStore(immutableReducer);