Last active
June 1, 2017 08:19
-
-
Save TapaniAla/c9d247edd7944ead372dea26ee30177e to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/cequnu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const todos = (state=[], action) => { | |
switch (action.type) { | |
case 'ADD_TODO': | |
return [ | |
...state, | |
{id: action.id, | |
text: action.text, | |
completed: false | |
} | |
]; | |
default: | |
return state; | |
} | |
}; | |
const testAddTodo = () => { | |
const stateBefore = []; | |
const action = { | |
type: 'ADD_TODO', | |
id: 0, | |
text: 'Learn Redux' | |
}; | |
const stateAfter = [ | |
{ | |
id: 0, | |
text: 'Learn Redux', | |
completed: false | |
} | |
]; | |
deepFreeze(stateBefore); | |
deepFreeze(action); | |
expect( | |
todos(stateBefore, action) | |
).toEqual(stateAfter); | |
}; | |
testAddTodo(); | |
console.log('Tests passed'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment