Created
June 29, 2016 15:54
-
-
Save anonymous/201afe8b0587791e76f049f517eb57c5 to your computer and use it in GitHub Desktop.
Partay // source https://jsbin.com/qiroju
This file contains hidden or 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> | |
<script src="https://wzrd.in/standalone/expect@latest"></script> | |
<script src="https://wzrd.in/standalone/deep-freeze@latest"></script> | |
<script src="https://fb.me/react-15.1.0.js"></script> | |
<script src="https://fb.me/react-dom-15.1.0.js"></script> | |
<meta charset="utf-8"> | |
<title>Partay</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
'use strict'; | |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |
var toggleTodo = function toggleTodo(todo) { | |
return _extends({}, todo, { | |
completed: !todo.completed | |
}); | |
}; | |
var testToggleTodo = function testToggleTodo() { | |
var todoBefore = { | |
id: 0, | |
text: 'Learn Redux', | |
completed: false | |
}; | |
var todoAfter = { | |
id: 0, | |
text: 'Learn Redux', | |
completed: true | |
}; | |
deepFreeze(todoBefore); | |
expect(toggleTodo(todoBefore)).toEqual(todoAfter); | |
}; | |
testToggleTodo(); | |
console.log('All tests passed'); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">const toggleTodo = (todo) => { | |
return { | |
...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 tests passed');</script></body> | |
</html> |
This file contains hidden or 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
'use strict'; | |
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | |
var toggleTodo = function toggleTodo(todo) { | |
return _extends({}, todo, { | |
completed: !todo.completed | |
}); | |
}; | |
var testToggleTodo = function testToggleTodo() { | |
var todoBefore = { | |
id: 0, | |
text: 'Learn Redux', | |
completed: false | |
}; | |
var todoAfter = { | |
id: 0, | |
text: 'Learn Redux', | |
completed: true | |
}; | |
deepFreeze(todoBefore); | |
expect(toggleTodo(todoBefore)).toEqual(todoAfter); | |
}; | |
testToggleTodo(); | |
console.log('All tests passed'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment