Skip to content

Instantly share code, notes, and snippets.

@ryanivandsouza
Created July 14, 2017 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanivandsouza/23a459eb3bdc8e5c96c8e0d7268e7c39 to your computer and use it in GitHub Desktop.
Save ryanivandsouza/23a459eb3bdc8e5c96c8e0d7268e7c39 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/nopabe
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://wzrd.in/standalone/expect@latest"></script>
<script src="https://wzrd.in/standalone/deep-freeze@latest"></script>
</head>
<body>
<script id="jsbin-javascript">
const toggleTodo = (todo) => {
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 tests passed!')
</script>
<script id="jsbin-source-javascript" type="text/javascript">const toggleTodo = (todo) => {
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 tests passed!')</script></body>
</html>
const toggleTodo = (todo) => {
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 tests passed!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment