Last active
October 29, 2017 00:22
-
-
Save th3mon/fa87ae5a9cda57f0d97d94b36c913656 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/muqigog
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/expect/1.20.2/expect.min.js"></script> | |
<script src="https://wzrd.in/standalone/deep-freeze@latest"></script> | |
<script id="jsbin-javascript"> | |
console.clear() | |
const toggleTodo = todo => { | |
// Spread operator on object is avaible in ES7 | |
return { | |
...todo, | |
completed: !todo.completed | |
} | |
// return Object.assign({}, todo, { | |
// completed: !todo.completed | |
// }) | |
} | |
const testToggleTodo = () => { | |
const todoBefore = { | |
id: 0, | |
text: 'Learn Redux', | |
completed: false | |
} | |
const todoAfter = { | |
id: 0, | |
text: 'Learn Redux', | |
completed: true | |
} | |
deepFreeze(todoBefore) | |
expect( | |
toggleTodo(todoBefore) | |
).toEqual(todoAfter) | |
} | |
testToggleTodo() | |
console.log('All test passed.') | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">console.clear() | |
const toggleTodo = todo => { | |
// Spread operator on object is avaible in ES7 | |
return { | |
...todo, | |
completed: !todo.completed | |
} | |
// return Object.assign({}, todo, { | |
// completed: !todo.completed | |
// }) | |
} | |
const testToggleTodo = () => { | |
const todoBefore = { | |
id: 0, | |
text: 'Learn Redux', | |
completed: false | |
} | |
const todoAfter = { | |
id: 0, | |
text: 'Learn Redux', | |
completed: true | |
} | |
deepFreeze(todoBefore) | |
expect( | |
toggleTodo(todoBefore) | |
).toEqual(todoAfter) | |
} | |
testToggleTodo() | |
console.log('All test passed.')</script></body> | |
</html> |
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
console.clear() | |
const toggleTodo = todo => { | |
// Spread operator on object is avaible in ES7 | |
return { | |
...todo, | |
completed: !todo.completed | |
} | |
// return Object.assign({}, todo, { | |
// completed: !todo.completed | |
// }) | |
} | |
const testToggleTodo = () => { | |
const todoBefore = { | |
id: 0, | |
text: 'Learn Redux', | |
completed: false | |
} | |
const todoAfter = { | |
id: 0, | |
text: 'Learn Redux', | |
completed: true | |
} | |
deepFreeze(todoBefore) | |
expect( | |
toggleTodo(todoBefore) | |
).toEqual(todoAfter) | |
} | |
testToggleTodo() | |
console.log('All test passed.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment