Created
October 20, 2018 18:38
-
-
Save lomse/a21a0c6ccf0c5003efd57b5171ca80c4 to your computer and use it in GitHub Desktop.
helper.test.js file
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
import { addTodo } from './helper' | |
describe('addTodo', () => { | |
it('should add todo to the list', () => { | |
const startTodos = [ | |
{ id: 1, name: 'one', isComplete: false }, | |
{ id: 2, name: 'two', isComplete: false } | |
] | |
const newTodo = { id: 3, name: 'three', isComplete: false } | |
const expected = [ | |
{ id: 3, name: 'three', isComplete: false }, | |
{ id: 1, name: 'one', isComplete: false }, | |
{ id: 2, name: 'two', isComplete: false } | |
] | |
const result = addTodo(startTodos, newTodo) | |
expect(result).toEqual(expected) | |
}) | |
it('should not mutate the existing todo array', () => { | |
const startTodos = [ | |
{ id: 1, name: 'one', isComplete: false }, | |
{ id: 2, name: 'two', isComplete: false } | |
] | |
const newTodo = { id: 3, name: 'three', isComplete: false } | |
const result = addTodo(startTodos, newTodo) | |
expect(result).not.toBe(startTodos) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment