Skip to content

Commit cbcdcc9

Browse files
authored
Refactor: set before-changed todos to deep copy of todos
1 parent aa7da66 commit cbcdcc9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sprint-3/todo-list/todos.test.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe("deleteTask()", () => {
4545

4646
test("Delete the first task", () => {
4747
const todos = createMockTodos();
48-
const todosBeforeDeletion = [...todos];
48+
const todosBeforeDeletion = createMockTodos();
4949
const lengthBeforeDeletion = todos.length;
5050
Todos.deleteTask(todos, 0);
5151

@@ -58,7 +58,7 @@ describe("deleteTask()", () => {
5858

5959
test("Delete the second task (a middle task)", () => {
6060
const todos = createMockTodos();
61-
const todosBeforeDeletion = [...todos];
61+
const todosBeforeDeletion = createMockTodos();
6262
const lengthBeforeDeletion = todos.length;
6363
Todos.deleteTask(todos, 1);
6464

@@ -71,7 +71,7 @@ describe("deleteTask()", () => {
7171

7272
test("Delete the last task", () => {
7373
const todos = createMockTodos();
74-
const todosBeforeDeletion = [...todos];
74+
const todosBeforeDeletion = createMockTodos();
7575
const lengthBeforeDeletion = todos.length;
7676
Todos.deleteTask(todos, todos.length - 1);
7777

@@ -84,7 +84,7 @@ describe("deleteTask()", () => {
8484

8585
test("Delete a non-existing task", () => {
8686
const todos = createMockTodos();
87-
const todosBeforeDeletion = [...todos];
87+
const todosBeforeDeletion = createMockTodos();
8888
Todos.deleteTask(todos, 10);
8989
expect(todos).toEqual(todosBeforeDeletion);
9090

@@ -109,7 +109,7 @@ describe("toggleCompletedOnTask()", () => {
109109

110110
test("Expect toggling on a task does not affect other tasks", () => {
111111
const todos = createMockTodos();
112-
const todosBeforeToggle = [...todos];
112+
const todosBeforeToggle = createMockTodos();
113113
Todos.toggleCompletedOnTask(todos, 1);
114114

115115
expect(todos[0]).toEqual(todosBeforeToggle[0]);
@@ -120,7 +120,7 @@ describe("toggleCompletedOnTask()", () => {
120120

121121
test("Expect no change when toggling on a non-existing task", () => {
122122
const todos = createMockTodos();
123-
const todosBeforeToggle = [...todos];
123+
const todosBeforeToggle = createMockTodos();
124124

125125
Todos.toggleCompletedOnTask(todos, 10);
126126
expect(todos).toEqual(todosBeforeToggle);

0 commit comments

Comments
 (0)