zamarrowski / Curso-React-Testing-GraphQL

Curso React, testing y GraphQL
36 stars 21 forks source link

testing #42

Closed zamarrowski closed 3 years ago

zamarrowski commented 3 years ago
export const editTodo = (todos, value, id) => {
  return todos.map(todo => {
    if (todo.id === id) todo.title = value
    return todo
  })
}
import { editTodo } from "./helpers"

test('Should edit a todo', () => {
  const todos = [{ id: 1, title: 'hola' }]
  const newMessage = 'editado!'
  const newTodos = editTodo(todos, newMessage, todos[0].id)
  expect(newTodos[0].title).toBe(newMessage)
})