Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. const toggleTodo = (todo) => {
  2. return {
  3. ...todo, // ES7
  4. completed: !todo.completed,
  5. };
  6.  
  7. /* ES6
  8. return Object.assign({}, todo, {
  9. completed: !todo.completed,
  10. });
  11.  
  12. */
  13. };
  14.  
  15. const testToggleTodo = () => {
  16. const todoBefore = {
  17. id: 0,
  18. test: 'Learn Redux',
  19. completed: false
  20. };
  21.  
  22. const todoAfter = {
  23. id: 0,
  24. test: 'Learn Redux',
  25. completed: true
  26. }
  27.  
  28. deepFreeze(todoBefore);
  29.  
  30. expect(
  31. toggleTodo(todoBefore)
  32. ).toEqual(todoAfter);
  33.  
  34. };
  35.  
  36. testToggleTodo();
  37. console.log('all tests passed');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement