-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodolist.test.js
29 lines (26 loc) · 909 Bytes
/
todolist.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* @jest-environment jsdom
*/
import ToDoList from './src/modules/todolist.js';
describe('Adding and removing tasks from the list', () => {
let toDoList;
beforeEach(() => {
toDoList = new ToDoList();
document.body.innerHTML = "<li class='todo-list'></li>";
localStorage.clear();
});
test('should add a new task to the list', () => {
toDoList.addToDo('test');
document.querySelector('.todo-list').innerHTML = toDoList.renderToDos();
const list = document.querySelectorAll('.todo-list .container');
expect(list).toHaveLength(1);
});
test('should remove a task from the list', () => {
toDoList.addToDo('test');
toDoList.addToDo('test2');
toDoList.removeToDo(1);
document.querySelector('.todo-list').innerHTML = toDoList.renderToDos();
const list = document.querySelectorAll('.todo-list .container');
expect(list).toHaveLength(1);
});
});