Write unit tests for this todo application. The code is located inside of src and you are going to write all your tests in __tests__/todo.js. Feel free to implement more functionality and test that functionality.
It can be a good idea to list all use cases (and potential errors) before starting
- I should be able to add a todo
- I should be able to remove a todo
- I should be able to remove all todos
- I should be able to edit a todo
- I should be not be able to edit a nonexisting todo
Then make your assertions based on those use cases.
git clone https://github.com/FEND16/unit-test-exercise
cd unit-test-exercise
yarn #or npm iSingle run
yarn testnpm run testWatch mode
yarn test:watchnpm run test:watchI have written a first test for you to start with:
/* So the functionalty is tested in isolation. This means
 * that each new test doesn't know anything about the previous
 * when mutating the state  (the list of todos) it is important
 * that we reset the state after each test */
beforeEach(() => {
  jest.resetModules();
});
test('returns all todos', () => {
  /* require the list for each test to guarantee isolated tests */
  const todoList = require('../src/todoList');
  expect(todoList.getAllTodos()).toHaveLength(4);
});Some example solutions is located under the branch solution