--- id: 5a24c314108439a4d4036150 title: Handle an Action in the Store challengeType: 6 isRequired: false videoUrl: '' localeTitle: '' --- ## Description undefined ## Instructions undefined ## Tests
```yml tests: - text: '' testString: 'assert(loginAction().type === "LOGIN", "Calling the function loginAction should return an object with type property set to the string LOGIN.");' - text: '' testString: 'assert(store.getState().login === false, "The store should be initialized with an object with property login set to false.");' - text: '' testString: 'assert((function() { const initialState = store.getState(); store.dispatch(loginAction()); const afterState = store.getState(); return initialState.login === false && afterState.login === true })(), "Dispatching loginAction should update the login property in the store state to true.");' - text: '' testString: 'assert((function() { store.dispatch({type: "__TEST__ACTION__"}); let afterTest = store.getState(); return typeof afterTest === "object" && afterTest.hasOwnProperty("login") })(), "If the action is not of type LOGIN, the store should return the current state.");' ```
## Challenge Seed
```jsx const defaultState = { login: false }; const reducer = (state = defaultState, action) => { // change code below this line // change code above this line }; const store = Redux.createStore(reducer); const loginAction = () => { return { type: 'LOGIN' } }; ```
## Solution
```js // solution required ```