From 7364afecf3fc467c12bd66da213df7a021130001 Mon Sep 17 00:00:00 2001 From: Dong young Date: Mon, 9 May 2022 16:30:05 +0900 Subject: [PATCH 01/14] 16:28 commit --- src/__tests__/todoItem.spec.js | 57 +++++++++++++++++++++++++++++++--- src/vo/TodoItem.js | 32 ++++++++++++++++++- 2 files changed, 84 insertions(+), 5 deletions(-) diff --git a/src/__tests__/todoItem.spec.js b/src/__tests__/todoItem.spec.js index decc062..33f540e 100644 --- a/src/__tests__/todoItem.spec.js +++ b/src/__tests__/todoItem.spec.js @@ -1,7 +1,56 @@ import TodoItem from "../vo/TodoItem"; -describe("테스트 그룹", () => { - test("테스트", () => { - expect(0).toEqual(0); +describe("create task", () => { + test("todo item create", () => { + const todoItem = new TodoItem(1, "drunk day"); + expect(todoItem.task).toEqual("drunk day"); }); -}); \ No newline at end of file +}); + +describe("update task", () => { + test("update todo", () => { + const todoItem = new TodoItem(1, "drunk day"); + todoItem.updateTask("quit") + expect(todoItem.task).toEqual("quit"); + }); +}); + +describe("task end or not", () => { + test("task end", () => { + const todoItem = new TodoItem(1, "drunk day"); + todoItem.setComplete(); + expect(todoItem.complete).toBeTruthy; + }); + + test("task end", () => { + const todoItem = new TodoItem(1, "drunk day"); + todoItem.unsetComplete(); + expect(todoItem.complete).toBeFalsy; + }); +}); + + +describe("date in task", () => { + test("today is true", () => { + const sourceDate = new Date(); + const targetDate = new Date(); + const todoItem = new TodoItem(1, "drunk day", sourceDate); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeTruthy; + }); + test("yesterday is false", () => { + const sourceDate = new Date('2022-05-08T10:00:00'); + const targetDate = new Date('2022-05-09T10:00:00'); + const todoItem = new TodoItem(1, "drunk day", sourceDate); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeFalsy; + }); +}); + + + + +describe("create task with complete", () => { + test("create task with complete", () => { + const todoItem = new TodoItem(1, "drunk day", new Date(), true); + expect(todoItem.completed).toBeTruthy; + }); +}); diff --git a/src/vo/TodoItem.js b/src/vo/TodoItem.js index 2ac7088..d1ed972 100644 --- a/src/vo/TodoItem.js +++ b/src/vo/TodoItem.js @@ -1,3 +1,4 @@ +import { toBeRequired } from "@testing-library/jest-dom/dist/matchers"; import { makeObservable, observable } from "mobx"; class TodoItem { @@ -12,11 +13,40 @@ class TodoItem { _createdAt = ""; _completed = false; - constructor() { + constructor(id, task, createdAt, completed=false) { makeObservable(this, { _task: observable, _completed: observable, }); + this._id = id; + this._task = task; + this._createdAt = createdAt; + this._completed = completed; + } + equalsDayOfCreatedAt = (_targetDate) => { + const sourceDate = new Date(this._createdAt).setHours(0, 0, 0, 0); + const targetDate = new Date(_targetDate).setHours(0, 0, 0, 0); + return sourceDate === targetDate; + /* + sourceDate.setHours(0, 0, 0, 0); + targetDate.setHours(0, 0, 0, 0); + return ( + sourceDate.getFullYear() === targetDate.getFullYear() && + sourceDate.getDate() === targetDate.getDate() && + sourceDate.getDay() === targetDate.getDay() + );*/ + } + + updateTask = (task) => { + this._task = task; + } + + setComplete = () => { + this._completed = true; + } + + unsetComplete = () => { + this._completed = false; } get id() { From 56d2e48dfbb29a10918c9255248c40dbd953026e Mon Sep 17 00:00:00 2001 From: Dong young Date: Mon, 9 May 2022 17:14:54 +0900 Subject: [PATCH 02/14] 17:13 commit --- src/__tests__/todoItem.spec.js | 2 - src/__tests__/todoList.spec.js | 96 ++++++++++++++++++++++++++++++++-- src/vo/TodoList.js | 36 ++++++++++++- 3 files changed, 128 insertions(+), 6 deletions(-) diff --git a/src/__tests__/todoItem.spec.js b/src/__tests__/todoItem.spec.js index 33f540e..581ab21 100644 --- a/src/__tests__/todoItem.spec.js +++ b/src/__tests__/todoItem.spec.js @@ -46,8 +46,6 @@ describe("date in task", () => { }); - - describe("create task with complete", () => { test("create task with complete", () => { const todoItem = new TodoItem(1, "drunk day", new Date(), true); diff --git a/src/__tests__/todoList.spec.js b/src/__tests__/todoList.spec.js index 17d1d5b..138dedd 100644 --- a/src/__tests__/todoList.spec.js +++ b/src/__tests__/todoList.spec.js @@ -1,8 +1,98 @@ import TodoItem from "../vo/TodoItem"; import TodoList from "../vo/TodoList"; -describe("테스트 그룹", () => { - test("테스트", () => { - expect(0).toEqual(0); +describe("have task list", () => { + test("create 5, have 5", () => { + const todoItem1 = new TodoItem(1, "task 1", new Date()); + const todoItem2 = new TodoItem(2, "task 2", new Date()); + const todoItem3 = new TodoItem(3, "task 3", new Date()); + const todoItem4 = new TodoItem(4, "task 4", new Date()); + const todoItem5 = new TodoItem(5, "task 5", new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + const todoList = new TodoList(todoItemList, new Date()); + expect(todoList.items).toHaveLength(5); }); }); + + +describe("delete task", () => { + test("in 5 task, delete id is 3", () => { + const todoItem1 = new TodoItem(1, "task 1", new Date()); + const todoItem2 = new TodoItem(2, "task 2", new Date()); + const todoItem3 = new TodoItem(3, "task 3", new Date()); + const todoItem4 = new TodoItem(4, "task 4", new Date()); + const todoItem5 = new TodoItem(5, "task 5", new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + const todoList = new TodoList(todoItemList, new Date()); + + todoList.removeTodoItem(3); + + //expect(todoList.items).toHaveLength(4); + expect(todoList.items.some((todoItem) => todoItem.id === 3)).toBeFalsy; + }); +}); + + + +describe("add task", () => { + test("in 5 task, delete id is 3", () => { + const todoItem1 = new TodoItem(1, "task 1", new Date()); + const todoItem2 = new TodoItem(2, "task 2", new Date()); + const todoItem3 = new TodoItem(3, "task 3", new Date()); + const todoItem4 = new TodoItem(4, "task 4", new Date()); + const todoItem5 = new TodoItem(5, "task 5", new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + const todoList = new TodoList(todoItemList, new Date()); + + + const todoItem6 = new TodoItem(6, "task 6", new Date()); + todoList.pushTodoItem(todoItem6); + + expect(todoList.items).toHaveLength(6); + expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy; + }); +}); + + + + +describe("separete today yesterday", () => { + test("5 tasks is today", () => { + const todoItem1 = new TodoItem(1, "task 1", new Date()); + const todoItem2 = new TodoItem(2, "task 2", new Date()); + const todoItem3 = new TodoItem(3, "task 3", new Date()); + const todoItem4 = new TodoItem(4, "task 4", new Date()); + const todoItem5 = new TodoItem(5, "task 5", new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + const todoList = new TodoList(todoItemList, new Date()); + + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + + expect(todoList.equalsDayItems).toHaveLength(4); + expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy; + }); + + + test("todoId 2 is yesterday task", () => { + const todoItem1 = new TodoItem(1, "task 1", new Date()); + const todoItem2 = new TodoItem(2, "task 2", new Date()); + const todoItem3 = new TodoItem(3, "task 3", new Date()); + const todoItem4 = new TodoItem(4, "task 4", new Date()); + const todoItem5 = new TodoItem(5, "task 5", new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + const todoList = new TodoList(todoItemList, new Date()); + + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + + expect(todoList.notEqualsDayItems).toHaveLength(1); + expect(todoList.notEqualsDayItems.some((todoItem) => todoItem.id === 2)).toBeFalsy; + }); + +}); + + + + + + + diff --git a/src/vo/TodoList.js b/src/vo/TodoList.js index 2685d97..42e799c 100644 --- a/src/vo/TodoList.js +++ b/src/vo/TodoList.js @@ -8,10 +8,44 @@ class TodoList { _items = []; _date = ""; - constructor() { + constructor(items, date) { makeObservable(this, { _items: observable, }); + this._items = items; + this._date = date; + } + + + _notequalsDayFilter = (todoItem) => !todoItem.equalsDayOfCreatedAt(this._date); + + get notEqualsDayItems() { + return this._items.filter(this._notequalsDayFilter); + + } + + _equalsDayFilter = (todoItem) => todoItem.equalsDayOfCreatedAt(this._date); + + get equalsDayItems() { + return this._items.filter(this._equalsDayFilter); + } + + + + pushTodoItem = (todoItem) => { + this._items.push(todoItem); + }; + + removeTodoItem = (todoId) => { + const targetTodoItemIndex = this._items.findIndex( + (todo) => todo.id === todoId + ); + if(targetTodoItemIndex === -1) return; + this._items.slice(targetTodoItemIndex, 1); + }; + + get items() { + return this._items; } } From a5c4c31fa0210fdc0aec4158f943e49bd80b2c83 Mon Sep 17 00:00:00 2001 From: Dong young Date: Mon, 9 May 2022 22:19:03 +0900 Subject: [PATCH 03/14] team-11-201802086 --- .vscode/launch.json | 15 +++ .../{ => 201802086}/todoItem.spec.js | 2 +- src/__tests__/201802086/todoList.spec.js | 114 ++++++++++++++++++ src/__tests__/todoList.spec.js | 98 --------------- src/vo/TodoList.js | 33 +++-- 5 files changed, 156 insertions(+), 106 deletions(-) create mode 100644 .vscode/launch.json rename src/__tests__/{ => 201802086}/todoItem.spec.js (97%) create mode 100644 src/__tests__/201802086/todoList.spec.js delete mode 100644 src/__tests__/todoList.spec.js diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e71e87d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // IntelliSense를 사용하여 가능한 특성에 대해 알아보세요. + // 기존 특성에 대한 설명을 보려면 가리킵니다. + // 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요. + "version": "0.2.0", + "configurations": [ + { + "type": "pwa-chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/src/__tests__/todoItem.spec.js b/src/__tests__/201802086/todoItem.spec.js similarity index 97% rename from src/__tests__/todoItem.spec.js rename to src/__tests__/201802086/todoItem.spec.js index 581ab21..81eeede 100644 --- a/src/__tests__/todoItem.spec.js +++ b/src/__tests__/201802086/todoItem.spec.js @@ -1,4 +1,4 @@ -import TodoItem from "../vo/TodoItem"; +import TodoItem from "../../vo/TodoItem"; describe("create task", () => { test("todo item create", () => { diff --git a/src/__tests__/201802086/todoList.spec.js b/src/__tests__/201802086/todoList.spec.js new file mode 100644 index 0000000..ec71308 --- /dev/null +++ b/src/__tests__/201802086/todoList.spec.js @@ -0,0 +1,114 @@ +import TodoItem from "../../vo/TodoItem"; +import TodoList from "../../vo/TodoList"; + +let todoItem1, todoItem2, todoItem3, todoItem4, todoItem5; +let todoList; + +beforeEach(() => { + todoItem1 = new TodoItem(1, "task 1", new Date()); + todoItem2 = new TodoItem(2, "task 2", new Date()); + todoItem3 = new TodoItem(3, "task 3", new Date()); + todoItem4 = new TodoItem(4, "task 4", new Date()); + todoItem5 = new TodoItem(5, "task 5", new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + todoList = new TodoList(todoItemList, new Date()); +}); + +describe("have task list", () => { + test("create 5, have 5", () => { + /*const todoItem1 = new TodoItem(1, "task 1", new Date()); + const todoItem2 = new TodoItem(2, "task 2", new Date()); + const todoItem3 = new TodoItem(3, "task 3", new Date()); + const todoItem4 = new TodoItem(4, "task 4", new Date()); + const todoItem5 = new TodoItem(5, "task 5", new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + const todoList = new TodoList(todoItemList, new Date());*/ + expect(todoList.items).toHaveLength(5); + }); +}); + + +describe("delete task", () => { + test("in 5 task, delete id is 3", () => { + todoList.removeTodoItem(3); + + expect(todoList.items).toHaveLength(4); + expect(todoList.items.some((todoItem) => todoItem.id === 3)).toBeFalsy; + }); +}); + + + +describe("add task", () => { + test("in 5 task, delete id is 3", () => { + + + const todoItem6 = new TodoItem(6, 'task 6', new Date()); + todoList.pushTodoItem(todoItem6); + expect(todoList.items).toHaveLength(6); + expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy(); + }); +}); + + + + +describe("separete today yesterday", () => { + test("5 tasks is today", () => { + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + + expect(todoList.equalsDayItems).toHaveLength(4); + expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy; + }); + + + test("todoId 2 is yesterday task", () => { + + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + + expect(todoList.notEqualsDayItems).toHaveLength(1); + expect(todoList.notEqualsDayItems.some((todoItem) => todoItem.id === 2)).toBeFalsy; + }); + +}); + + + + + +describe("separete complete or not", () => { + test("in 5, 2 and 3 is complete", () => { + jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + expect(todoList.notEqualsDayAndCompletedItems).toHaveLength(2); + }); + + + test("in 5, 2 and 4 is not completed", () => { + jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(2); + }); + +}); + + + + + + + + + + diff --git a/src/__tests__/todoList.spec.js b/src/__tests__/todoList.spec.js deleted file mode 100644 index 138dedd..0000000 --- a/src/__tests__/todoList.spec.js +++ /dev/null @@ -1,98 +0,0 @@ -import TodoItem from "../vo/TodoItem"; -import TodoList from "../vo/TodoList"; - -describe("have task list", () => { - test("create 5, have 5", () => { - const todoItem1 = new TodoItem(1, "task 1", new Date()); - const todoItem2 = new TodoItem(2, "task 2", new Date()); - const todoItem3 = new TodoItem(3, "task 3", new Date()); - const todoItem4 = new TodoItem(4, "task 4", new Date()); - const todoItem5 = new TodoItem(5, "task 5", new Date()); - const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; - const todoList = new TodoList(todoItemList, new Date()); - expect(todoList.items).toHaveLength(5); - }); -}); - - -describe("delete task", () => { - test("in 5 task, delete id is 3", () => { - const todoItem1 = new TodoItem(1, "task 1", new Date()); - const todoItem2 = new TodoItem(2, "task 2", new Date()); - const todoItem3 = new TodoItem(3, "task 3", new Date()); - const todoItem4 = new TodoItem(4, "task 4", new Date()); - const todoItem5 = new TodoItem(5, "task 5", new Date()); - const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; - const todoList = new TodoList(todoItemList, new Date()); - - todoList.removeTodoItem(3); - - //expect(todoList.items).toHaveLength(4); - expect(todoList.items.some((todoItem) => todoItem.id === 3)).toBeFalsy; - }); -}); - - - -describe("add task", () => { - test("in 5 task, delete id is 3", () => { - const todoItem1 = new TodoItem(1, "task 1", new Date()); - const todoItem2 = new TodoItem(2, "task 2", new Date()); - const todoItem3 = new TodoItem(3, "task 3", new Date()); - const todoItem4 = new TodoItem(4, "task 4", new Date()); - const todoItem5 = new TodoItem(5, "task 5", new Date()); - const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; - const todoList = new TodoList(todoItemList, new Date()); - - - const todoItem6 = new TodoItem(6, "task 6", new Date()); - todoList.pushTodoItem(todoItem6); - - expect(todoList.items).toHaveLength(6); - expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy; - }); -}); - - - - -describe("separete today yesterday", () => { - test("5 tasks is today", () => { - const todoItem1 = new TodoItem(1, "task 1", new Date()); - const todoItem2 = new TodoItem(2, "task 2", new Date()); - const todoItem3 = new TodoItem(3, "task 3", new Date()); - const todoItem4 = new TodoItem(4, "task 4", new Date()); - const todoItem5 = new TodoItem(5, "task 5", new Date()); - const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; - const todoList = new TodoList(todoItemList, new Date()); - - jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); - - expect(todoList.equalsDayItems).toHaveLength(4); - expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy; - }); - - - test("todoId 2 is yesterday task", () => { - const todoItem1 = new TodoItem(1, "task 1", new Date()); - const todoItem2 = new TodoItem(2, "task 2", new Date()); - const todoItem3 = new TodoItem(3, "task 3", new Date()); - const todoItem4 = new TodoItem(4, "task 4", new Date()); - const todoItem5 = new TodoItem(5, "task 5", new Date()); - const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; - const todoList = new TodoList(todoItemList, new Date()); - - jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); - - expect(todoList.notEqualsDayItems).toHaveLength(1); - expect(todoList.notEqualsDayItems.some((todoItem) => todoItem.id === 2)).toBeFalsy; - }); - -}); - - - - - - - diff --git a/src/vo/TodoList.js b/src/vo/TodoList.js index 42e799c..385ebf7 100644 --- a/src/vo/TodoList.js +++ b/src/vo/TodoList.js @@ -1,4 +1,5 @@ import { makeObservable, observable } from "mobx"; +import TodoItem from "../vo/TodoItem"; class TodoList { /* @@ -16,16 +17,34 @@ class TodoList { this._date = date; } - + _equalsDayFilter = (todoItem) => todoItem.equalsDayOfCreatedAt(this._date); _notequalsDayFilter = (todoItem) => !todoItem.equalsDayOfCreatedAt(this._date); + _completedFilter = (todoItem) => todoItem.completed; + _notCompletedFilter = (todoItem) => !todoItem.completed; - get notEqualsDayItems() { - return this._items.filter(this._notequalsDayFilter); + + get notEqualsDayAndCompletedItems() { + return this.notEqualsDayItems.filter(this._completedFilter); + } + + get notEqualsDayAndNotCompletedItems() { + return this.notEqualsDayItems.filter(this._notCompletedFilter); } - _equalsDayFilter = (todoItem) => todoItem.equalsDayOfCreatedAt(this._date); + get equalsDayAndCompletedItems() { + return this.equalsDayItems.filter(this._completedFilter); + } + get equalsDayAndNotCompletedItems() { + return this.equalsDayItems.filter(this._notCompletedFilter); + + } + + + get notEqualsDayItems() { + return this._items.filter(this._notequalsDayFilter); + } get equalsDayItems() { return this._items.filter(this._equalsDayFilter); } @@ -38,10 +57,10 @@ class TodoList { removeTodoItem = (todoId) => { const targetTodoItemIndex = this._items.findIndex( - (todo) => todo.id === todoId + (todo) => todo.id === todoId ); - if(targetTodoItemIndex === -1) return; - this._items.slice(targetTodoItemIndex, 1); + if (targetTodoItemIndex === -1) return; + this._items.splice(targetTodoItemIndex, 1); }; get items() { From 9b7fdea76ec599b1ba082d1a91c391d23e3fdb47 Mon Sep 17 00:00:00 2001 From: tnghwk0661 Date: Wed, 11 May 2022 19:07:55 +0900 Subject: [PATCH 04/14] up-to-date --- src/__tests__/201802054/todoItem.spec.js | 51 +++++++++++++ src/__tests__/201802054/todoList.spec.js | 91 ++++++++++++++++++++++++ src/__tests__/todoItem.spec.js | 7 -- src/__tests__/todoList.spec.js | 8 --- src/vo/TodoItem.js | 28 +++++++- src/vo/TodoList.js | 51 ++++++++++++- 6 files changed, 215 insertions(+), 21 deletions(-) create mode 100644 src/__tests__/201802054/todoItem.spec.js create mode 100644 src/__tests__/201802054/todoList.spec.js delete mode 100644 src/__tests__/todoItem.spec.js delete mode 100644 src/__tests__/todoList.spec.js diff --git a/src/__tests__/201802054/todoItem.spec.js b/src/__tests__/201802054/todoItem.spec.js new file mode 100644 index 0000000..4076147 --- /dev/null +++ b/src/__tests__/201802054/todoItem.spec.js @@ -0,0 +1,51 @@ +import TodoItem from "../../vo/TodoItem"; + +describe("할 일을 만들 수 있다.", () => { + test("todo item 생성하기", () => { + const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); + expect(todoItem.task).toEqual('오늘은 술 먹는 날'); + }); +}); + +describe("할 일을 업데이트 할 수 있다.", () => { + test("todo item 업데이트 하기", () => { + const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); + todoItem.updateTask('오늘은 그냥 안 마실래'); + expect(todoItem.task).toEqual('오늘은 그냥 안 마실래'); + }); +}); + +describe("할 일을 완료/미완료로 바꿀 수 있다.", () => { + test("todo item 완료로 바꾸기", () => { + const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); + todoItem.setComplete(); + expect(todoItem.completed).toBeTruthy(); + }); + test("todo item 미완료로 바꾸기", () => { + const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); + todoItem.unsetComplete(); + expect(todoItem.completed).toBeFalsy(); + }); +}); + +describe("할 일에 날짜가 들어간다.", () => { + test("todo item이 오늘 만들었으면, isToday가 true이다.", () => { + const sourceDate = new Date(); + const targetDate = new Date(); + const todoItem = new TodoItem(1, '오늘은 술 먹는 날', sourceDate); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeTruthy(); + }); + test("todo item이 어제 만들었으면, isToday가 false이다.", () => { + const sourceDate = new Date('2022-05-08T10:00:00'); + const targetDate = new Date('2022-05-09T10:00:00'); + const todoItem = new TodoItem(1, '오늘은 술 먹는 날', sourceDate); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeFalsy(); + }); +}); + +describe("할 일을 완료로 바꿀 수 있다.", () => { + test("todo item 완료로 바꾸기", () => { + const todoItem = new TodoItem(1, '오늘은 술 먹는 날', new Date(), true); + expect(todoItem.completed).toBeTruthy(); + }); +}); \ No newline at end of file diff --git a/src/__tests__/201802054/todoList.spec.js b/src/__tests__/201802054/todoList.spec.js new file mode 100644 index 0000000..a6addfa --- /dev/null +++ b/src/__tests__/201802054/todoList.spec.js @@ -0,0 +1,91 @@ +import TodoItem from "../../vo/TodoItem"; +import TodoList from "../../vo/TodoList"; + +let todoItem1, todoItem2, todoItem3, todoItem4, todoItem5; +let todoList; + +beforeEach(() => { + todoItem1 = new TodoItem(1, '할 일 1', new Date()); + todoItem2 = new TodoItem(2, '할 일 2', new Date()); + todoItem3 = new TodoItem(3, '할 일 3', new Date()); + todoItem4 = new TodoItem(4, '할 일 4', new Date()); + todoItem5 = new TodoItem(5, '할 일 5', new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5] + todoList = new TodoList(todoItemList, new Date()); +}); + +describe("할 일 목록을 가지고 있다.", () => { + test("5개를 만들면, 5개가 있다.", () => { + const todoItem1 = new TodoItem(1, '할 일 1', new Date()); + const todoItem2 = new TodoItem(2, '할 일 2', new Date()); + const todoItem3 = new TodoItem(3, '할 일 3', new Date()); + const todoItem4 = new TodoItem(4, '할 일 4', new Date()); + const todoItem5 = new TodoItem(5, '할 일 5', new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + const todoList = new TodoList(todoItemList); + expect(todoList.items).toHaveLength(5); + }); +}); + +describe("할 일 목록에서 할 일을 삭제할 수 있다.", () => { + test("5개의 할 일이 있는데 id가 3인 일을 삭제할 수 있다.", () => { + todoList.removeTodoItem(3); + expect(todoList.items).toHaveLength(4); + expect(todoList.items.some((todoItem) => todoItem.id === 3)).toBeFalsy(); + }); +}); + +describe("할 일 목록에서 할 일을 추가할 수 있다.", () => { + test("5개의 할 일이 있는데 할 일을 추가할 수 있다.", () => { + const todoItem6 = new TodoItem(6, '할 일 6', new Date()); + todoList.pushTodoItem(todoItem6); + expect(todoList.items).toHaveLength(6); + expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy(); + }); +}); + +describe("생성한 할 일들 중에서 오늘 할 일, 지난 할 일 구분하기", () => { + test("5개의 할 일이 있는데 2번 빼고, 오늘 만들 일이다.", () => { + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + + expect(todoList.equalsDayItems).toHaveLength(4); + expect(todoList.equalsDayItems.some((todoItem) => todoItem.id === 2)).toBeFalsy(); + }); + + test("5개의 할 일이 있는데 id 2만 지난 할 일이다.", () => { + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + + expect(todoList.notequalsDayItems).toHaveLength(1); + expect(todoList.notequalsDayItems.some((todoItem) => todoItem.id === 2)).toBeTruthy(); + }); +}); + +describe("오늘 할 일 중 완료/미완료 구분하기", () => { + test("5개의 할 일이 있는데 2번, 3번만 완료다.", () => { + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + expect(todoList.equalsDayAndCompletedItems).toHaveLength(2); + }); + + test("5개의 할 일이 있는데 2번, 4번만 미완료다.", () => { + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(true); + expect(todoList.equalsDayAndNotCompletedItems).toHaveLength(3); + }); +}); + +describe("지난 할 일 중 완료/미완료 구분하기", () => { + test("5개의 지난 할 일이 있는데 2번, 3번만 완료다.", () => { + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + expect(todoList.equalsDayAndCompletedItems).toHaveLength(2); + }); + + test("5개의 지난 할 일이 있는데 2번, 4번만 미완료다.", () => { + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(true); + expect(todoList.equalsDayAndNotCompletedItems).toHaveLength(3); + }); +}); \ No newline at end of file diff --git a/src/__tests__/todoItem.spec.js b/src/__tests__/todoItem.spec.js deleted file mode 100644 index decc062..0000000 --- a/src/__tests__/todoItem.spec.js +++ /dev/null @@ -1,7 +0,0 @@ -import TodoItem from "../vo/TodoItem"; - -describe("테스트 그룹", () => { - test("테스트", () => { - expect(0).toEqual(0); - }); -}); \ No newline at end of file diff --git a/src/__tests__/todoList.spec.js b/src/__tests__/todoList.spec.js deleted file mode 100644 index 17d1d5b..0000000 --- a/src/__tests__/todoList.spec.js +++ /dev/null @@ -1,8 +0,0 @@ -import TodoItem from "../vo/TodoItem"; -import TodoList from "../vo/TodoList"; - -describe("테스트 그룹", () => { - test("테스트", () => { - expect(0).toEqual(0); - }); -}); diff --git a/src/vo/TodoItem.js b/src/vo/TodoItem.js index 2ac7088..999b25e 100644 --- a/src/vo/TodoItem.js +++ b/src/vo/TodoItem.js @@ -1,4 +1,4 @@ -import { makeObservable, observable } from "mobx"; +import { makeObservable, observable, action, computed } from "mobx"; class TodoItem { /* @@ -12,13 +12,35 @@ class TodoItem { _createdAt = ""; _completed = false; - constructor() { + constructor(id, task, createdAt, completed = false) { makeObservable(this, { _task: observable, _completed: observable, }); + this._id = id; + this._task = task; + this._createdAt = createdAt; + this._completed = completed; } + updateTask = (task) => { + this._task = task; + }; + + setComplete = () => { + this._completed = true; + }; + + unsetComplete = () => { + this._completed = false; + }; + + equalsDayOfCreatedAt = (date) => { + const sourceDate = new Date(this._createdAt).setHours(0, 0, 0, 0); + const targetDate = new Date(date).setHours(0, 0, 0, 0); + return sourceDate === targetDate; + }; + get id() { return this._id; } @@ -38,4 +60,4 @@ class TodoItem { } } -export default TodoItem; +export default TodoItem; \ No newline at end of file diff --git a/src/vo/TodoList.js b/src/vo/TodoList.js index 2685d97..748775d 100644 --- a/src/vo/TodoList.js +++ b/src/vo/TodoList.js @@ -1,4 +1,4 @@ -import { makeObservable, observable } from "mobx"; +import { makeObservable, observable, action, computed } from "mobx"; class TodoList { /* @@ -8,11 +8,56 @@ class TodoList { _items = []; _date = ""; - constructor() { + constructor(items, date) { makeObservable(this, { _items: observable, }); + this._items = items || []; + this._date = date; } + + _completedFilter = (todoItem) => todoItem.completed; + _notCompletedFilter = (todoItem) => !todoItem.completed; + + _equalsDayFilter = (todoItem) => todoItem.equalsDayOfCreatedAt(this._date); + _notEqualsDayFilter = (todoItem) => + !todoItem.equalsDayOfCreatedAt(this._date); + + get equalsDayItems() { + return this._items.filter(this._equalsDayFilter); + } + + get equalsDayAndCompletedItems() { + return this.equalsDayItems.filter(this._completedFilter); + } + + get equalsDayAndNotCompletedItems() { + return this.equalsDayItems.filter(this._notCompletedFilter); + } + + get notEqualsDayItems() { + return this._items.filter(this._notEqualsDayFilter); + } + + get notEqualsDayAndCompletedItems() { + return this.notEqualsDayItems.filter(this._completedFilter); + } + + get notEqualsDayAndNotCompletedItems() { + return this.notEqualsDayItems.filter(this._notCompletedFilter); + } + + pushTodoItem = (todoItem) => { + this._items.push(todoItem); + }; + + removeTodoItem = (todoId) => { + const targetTodoItemIndex = this._items.findIndex( + (todo) => todo.id === todoId + ); + if (targetTodoItemIndex === -1) return; + this._items.splice(targetTodoItemIndex, 1); + }; } -export default TodoList; +export default TodoList; \ No newline at end of file From 4f6e2c4e8f152ca4322a959f2603ff410408b42f Mon Sep 17 00:00:00 2001 From: tnghwk0661 Date: Wed, 11 May 2022 19:12:51 +0900 Subject: [PATCH 05/14] up-to-date --- src/vo/TodoItem.js | 37 ---------------------------- src/vo/TodoList.js | 60 ---------------------------------------------- 2 files changed, 97 deletions(-) diff --git a/src/vo/TodoItem.js b/src/vo/TodoItem.js index 5cd024b..999b25e 100644 --- a/src/vo/TodoItem.js +++ b/src/vo/TodoItem.js @@ -1,9 +1,4 @@ -<<<<<<< HEAD import { makeObservable, observable, action, computed } from "mobx"; -======= -import { toBeRequired } from "@testing-library/jest-dom/dist/matchers"; -import { makeObservable, observable } from "mobx"; ->>>>>>> fb97e263f7bf22c290127cecfde9a89173714997 class TodoItem { /* @@ -17,11 +12,7 @@ class TodoItem { _createdAt = ""; _completed = false; -<<<<<<< HEAD constructor(id, task, createdAt, completed = false) { -======= - constructor(id, task, createdAt, completed=false) { ->>>>>>> fb97e263f7bf22c290127cecfde9a89173714997 makeObservable(this, { _task: observable, _completed: observable, @@ -30,34 +21,6 @@ class TodoItem { this._task = task; this._createdAt = createdAt; this._completed = completed; -<<<<<<< HEAD -======= - } - equalsDayOfCreatedAt = (_targetDate) => { - const sourceDate = new Date(this._createdAt).setHours(0, 0, 0, 0); - const targetDate = new Date(_targetDate).setHours(0, 0, 0, 0); - return sourceDate === targetDate; - /* - sourceDate.setHours(0, 0, 0, 0); - targetDate.setHours(0, 0, 0, 0); - return ( - sourceDate.getFullYear() === targetDate.getFullYear() && - sourceDate.getDate() === targetDate.getDate() && - sourceDate.getDay() === targetDate.getDay() - );*/ - } - - updateTask = (task) => { - this._task = task; - } - - setComplete = () => { - this._completed = true; - } - - unsetComplete = () => { - this._completed = false; ->>>>>>> fb97e263f7bf22c290127cecfde9a89173714997 } updateTask = (task) => { diff --git a/src/vo/TodoList.js b/src/vo/TodoList.js index 38ed489..748775d 100644 --- a/src/vo/TodoList.js +++ b/src/vo/TodoList.js @@ -1,9 +1,4 @@ -<<<<<<< HEAD import { makeObservable, observable, action, computed } from "mobx"; -======= -import { makeObservable, observable } from "mobx"; -import TodoItem from "../vo/TodoItem"; ->>>>>>> fb97e263f7bf22c290127cecfde9a89173714997 class TodoList { /* @@ -17,63 +12,8 @@ class TodoList { makeObservable(this, { _items: observable, }); -<<<<<<< HEAD this._items = items || []; this._date = date; -======= - this._items = items; - this._date = date; - } - - _equalsDayFilter = (todoItem) => todoItem.equalsDayOfCreatedAt(this._date); - _notequalsDayFilter = (todoItem) => !todoItem.equalsDayOfCreatedAt(this._date); - _completedFilter = (todoItem) => todoItem.completed; - _notCompletedFilter = (todoItem) => !todoItem.completed; - - - get notEqualsDayAndCompletedItems() { - return this.notEqualsDayItems.filter(this._completedFilter); - } - - get notEqualsDayAndNotCompletedItems() { - return this.notEqualsDayItems.filter(this._notCompletedFilter); - - } - - get equalsDayAndCompletedItems() { - return this.equalsDayItems.filter(this._completedFilter); - } - get equalsDayAndNotCompletedItems() { - return this.equalsDayItems.filter(this._notCompletedFilter); - - } - - - - get notEqualsDayItems() { - return this._items.filter(this._notequalsDayFilter); - } - get equalsDayItems() { - return this._items.filter(this._equalsDayFilter); - } - - - - pushTodoItem = (todoItem) => { - this._items.push(todoItem); - }; - - removeTodoItem = (todoId) => { - const targetTodoItemIndex = this._items.findIndex( - (todo) => todo.id === todoId - ); - if (targetTodoItemIndex === -1) return; - this._items.splice(targetTodoItemIndex, 1); - }; - - get items() { - return this._items; ->>>>>>> fb97e263f7bf22c290127cecfde9a89173714997 } _completedFilter = (todoItem) => todoItem.completed; From 252624aecfd1e531617b99f449226bf8c4bee4e1 Mon Sep 17 00:00:00 2001 From: sungwoochang Date: Wed, 11 May 2022 19:41:31 +0900 Subject: [PATCH 06/14] 5/11 19:41/ 201802109 --- src/__tests__/201802054/todoItem.spec.js | 51 ---------- src/__tests__/201802054/todoList.spec.js | 91 ------------------ src/__tests__/201802086/todoItem.spec.js | 54 ----------- src/__tests__/201802086/todoList.spec.js | 114 ----------------------- src/__tests__/201802109/todoItem.spec.js | 39 ++++++++ src/__tests__/201802109/todoList.spec.js | 103 ++++++++++++++++++++ 6 files changed, 142 insertions(+), 310 deletions(-) delete mode 100644 src/__tests__/201802054/todoItem.spec.js delete mode 100644 src/__tests__/201802054/todoList.spec.js delete mode 100644 src/__tests__/201802086/todoItem.spec.js delete mode 100644 src/__tests__/201802086/todoList.spec.js create mode 100644 src/__tests__/201802109/todoItem.spec.js create mode 100644 src/__tests__/201802109/todoList.spec.js diff --git a/src/__tests__/201802054/todoItem.spec.js b/src/__tests__/201802054/todoItem.spec.js deleted file mode 100644 index 4076147..0000000 --- a/src/__tests__/201802054/todoItem.spec.js +++ /dev/null @@ -1,51 +0,0 @@ -import TodoItem from "../../vo/TodoItem"; - -describe("할 일을 만들 수 있다.", () => { - test("todo item 생성하기", () => { - const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); - expect(todoItem.task).toEqual('오늘은 술 먹는 날'); - }); -}); - -describe("할 일을 업데이트 할 수 있다.", () => { - test("todo item 업데이트 하기", () => { - const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); - todoItem.updateTask('오늘은 그냥 안 마실래'); - expect(todoItem.task).toEqual('오늘은 그냥 안 마실래'); - }); -}); - -describe("할 일을 완료/미완료로 바꿀 수 있다.", () => { - test("todo item 완료로 바꾸기", () => { - const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); - todoItem.setComplete(); - expect(todoItem.completed).toBeTruthy(); - }); - test("todo item 미완료로 바꾸기", () => { - const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); - todoItem.unsetComplete(); - expect(todoItem.completed).toBeFalsy(); - }); -}); - -describe("할 일에 날짜가 들어간다.", () => { - test("todo item이 오늘 만들었으면, isToday가 true이다.", () => { - const sourceDate = new Date(); - const targetDate = new Date(); - const todoItem = new TodoItem(1, '오늘은 술 먹는 날', sourceDate); - expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeTruthy(); - }); - test("todo item이 어제 만들었으면, isToday가 false이다.", () => { - const sourceDate = new Date('2022-05-08T10:00:00'); - const targetDate = new Date('2022-05-09T10:00:00'); - const todoItem = new TodoItem(1, '오늘은 술 먹는 날', sourceDate); - expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeFalsy(); - }); -}); - -describe("할 일을 완료로 바꿀 수 있다.", () => { - test("todo item 완료로 바꾸기", () => { - const todoItem = new TodoItem(1, '오늘은 술 먹는 날', new Date(), true); - expect(todoItem.completed).toBeTruthy(); - }); -}); \ No newline at end of file diff --git a/src/__tests__/201802054/todoList.spec.js b/src/__tests__/201802054/todoList.spec.js deleted file mode 100644 index a6addfa..0000000 --- a/src/__tests__/201802054/todoList.spec.js +++ /dev/null @@ -1,91 +0,0 @@ -import TodoItem from "../../vo/TodoItem"; -import TodoList from "../../vo/TodoList"; - -let todoItem1, todoItem2, todoItem3, todoItem4, todoItem5; -let todoList; - -beforeEach(() => { - todoItem1 = new TodoItem(1, '할 일 1', new Date()); - todoItem2 = new TodoItem(2, '할 일 2', new Date()); - todoItem3 = new TodoItem(3, '할 일 3', new Date()); - todoItem4 = new TodoItem(4, '할 일 4', new Date()); - todoItem5 = new TodoItem(5, '할 일 5', new Date()); - const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5] - todoList = new TodoList(todoItemList, new Date()); -}); - -describe("할 일 목록을 가지고 있다.", () => { - test("5개를 만들면, 5개가 있다.", () => { - const todoItem1 = new TodoItem(1, '할 일 1', new Date()); - const todoItem2 = new TodoItem(2, '할 일 2', new Date()); - const todoItem3 = new TodoItem(3, '할 일 3', new Date()); - const todoItem4 = new TodoItem(4, '할 일 4', new Date()); - const todoItem5 = new TodoItem(5, '할 일 5', new Date()); - const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; - const todoList = new TodoList(todoItemList); - expect(todoList.items).toHaveLength(5); - }); -}); - -describe("할 일 목록에서 할 일을 삭제할 수 있다.", () => { - test("5개의 할 일이 있는데 id가 3인 일을 삭제할 수 있다.", () => { - todoList.removeTodoItem(3); - expect(todoList.items).toHaveLength(4); - expect(todoList.items.some((todoItem) => todoItem.id === 3)).toBeFalsy(); - }); -}); - -describe("할 일 목록에서 할 일을 추가할 수 있다.", () => { - test("5개의 할 일이 있는데 할 일을 추가할 수 있다.", () => { - const todoItem6 = new TodoItem(6, '할 일 6', new Date()); - todoList.pushTodoItem(todoItem6); - expect(todoList.items).toHaveLength(6); - expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy(); - }); -}); - -describe("생성한 할 일들 중에서 오늘 할 일, 지난 할 일 구분하기", () => { - test("5개의 할 일이 있는데 2번 빼고, 오늘 만들 일이다.", () => { - jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); - - expect(todoList.equalsDayItems).toHaveLength(4); - expect(todoList.equalsDayItems.some((todoItem) => todoItem.id === 2)).toBeFalsy(); - }); - - test("5개의 할 일이 있는데 id 2만 지난 할 일이다.", () => { - jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); - - expect(todoList.notequalsDayItems).toHaveLength(1); - expect(todoList.notequalsDayItems.some((todoItem) => todoItem.id === 2)).toBeTruthy(); - }); -}); - -describe("오늘 할 일 중 완료/미완료 구분하기", () => { - test("5개의 할 일이 있는데 2번, 3번만 완료다.", () => { - jest.spyOn(todoItem2, "completed", "get").mockReturnValue(true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); - expect(todoList.equalsDayAndCompletedItems).toHaveLength(2); - }); - - test("5개의 할 일이 있는데 2번, 4번만 미완료다.", () => { - jest.spyOn(todoItem1, "completed", "get").mockReturnValue(true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); - jest.spyOn(todoItem5, "completed", "get").mockReturnValue(true); - expect(todoList.equalsDayAndNotCompletedItems).toHaveLength(3); - }); -}); - -describe("지난 할 일 중 완료/미완료 구분하기", () => { - test("5개의 지난 할 일이 있는데 2번, 3번만 완료다.", () => { - jest.spyOn(todoItem2, "completed", "get").mockReturnValue(true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); - expect(todoList.equalsDayAndCompletedItems).toHaveLength(2); - }); - - test("5개의 지난 할 일이 있는데 2번, 4번만 미완료다.", () => { - jest.spyOn(todoItem1, "completed", "get").mockReturnValue(true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); - jest.spyOn(todoItem5, "completed", "get").mockReturnValue(true); - expect(todoList.equalsDayAndNotCompletedItems).toHaveLength(3); - }); -}); \ No newline at end of file diff --git a/src/__tests__/201802086/todoItem.spec.js b/src/__tests__/201802086/todoItem.spec.js deleted file mode 100644 index 81eeede..0000000 --- a/src/__tests__/201802086/todoItem.spec.js +++ /dev/null @@ -1,54 +0,0 @@ -import TodoItem from "../../vo/TodoItem"; - -describe("create task", () => { - test("todo item create", () => { - const todoItem = new TodoItem(1, "drunk day"); - expect(todoItem.task).toEqual("drunk day"); - }); -}); - -describe("update task", () => { - test("update todo", () => { - const todoItem = new TodoItem(1, "drunk day"); - todoItem.updateTask("quit") - expect(todoItem.task).toEqual("quit"); - }); -}); - -describe("task end or not", () => { - test("task end", () => { - const todoItem = new TodoItem(1, "drunk day"); - todoItem.setComplete(); - expect(todoItem.complete).toBeTruthy; - }); - - test("task end", () => { - const todoItem = new TodoItem(1, "drunk day"); - todoItem.unsetComplete(); - expect(todoItem.complete).toBeFalsy; - }); -}); - - -describe("date in task", () => { - test("today is true", () => { - const sourceDate = new Date(); - const targetDate = new Date(); - const todoItem = new TodoItem(1, "drunk day", sourceDate); - expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeTruthy; - }); - test("yesterday is false", () => { - const sourceDate = new Date('2022-05-08T10:00:00'); - const targetDate = new Date('2022-05-09T10:00:00'); - const todoItem = new TodoItem(1, "drunk day", sourceDate); - expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeFalsy; - }); -}); - - -describe("create task with complete", () => { - test("create task with complete", () => { - const todoItem = new TodoItem(1, "drunk day", new Date(), true); - expect(todoItem.completed).toBeTruthy; - }); -}); diff --git a/src/__tests__/201802086/todoList.spec.js b/src/__tests__/201802086/todoList.spec.js deleted file mode 100644 index ec71308..0000000 --- a/src/__tests__/201802086/todoList.spec.js +++ /dev/null @@ -1,114 +0,0 @@ -import TodoItem from "../../vo/TodoItem"; -import TodoList from "../../vo/TodoList"; - -let todoItem1, todoItem2, todoItem3, todoItem4, todoItem5; -let todoList; - -beforeEach(() => { - todoItem1 = new TodoItem(1, "task 1", new Date()); - todoItem2 = new TodoItem(2, "task 2", new Date()); - todoItem3 = new TodoItem(3, "task 3", new Date()); - todoItem4 = new TodoItem(4, "task 4", new Date()); - todoItem5 = new TodoItem(5, "task 5", new Date()); - const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; - todoList = new TodoList(todoItemList, new Date()); -}); - -describe("have task list", () => { - test("create 5, have 5", () => { - /*const todoItem1 = new TodoItem(1, "task 1", new Date()); - const todoItem2 = new TodoItem(2, "task 2", new Date()); - const todoItem3 = new TodoItem(3, "task 3", new Date()); - const todoItem4 = new TodoItem(4, "task 4", new Date()); - const todoItem5 = new TodoItem(5, "task 5", new Date()); - const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; - const todoList = new TodoList(todoItemList, new Date());*/ - expect(todoList.items).toHaveLength(5); - }); -}); - - -describe("delete task", () => { - test("in 5 task, delete id is 3", () => { - todoList.removeTodoItem(3); - - expect(todoList.items).toHaveLength(4); - expect(todoList.items.some((todoItem) => todoItem.id === 3)).toBeFalsy; - }); -}); - - - -describe("add task", () => { - test("in 5 task, delete id is 3", () => { - - - const todoItem6 = new TodoItem(6, 'task 6', new Date()); - todoList.pushTodoItem(todoItem6); - expect(todoList.items).toHaveLength(6); - expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy(); - }); -}); - - - - -describe("separete today yesterday", () => { - test("5 tasks is today", () => { - jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); - - expect(todoList.equalsDayItems).toHaveLength(4); - expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy; - }); - - - test("todoId 2 is yesterday task", () => { - - jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); - - expect(todoList.notEqualsDayItems).toHaveLength(1); - expect(todoList.notEqualsDayItems.some((todoItem) => todoItem.id === 2)).toBeFalsy; - }); - -}); - - - - - -describe("separete complete or not", () => { - test("in 5, 2 and 3 is complete", () => { - jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); - expect(todoList.notEqualsDayAndCompletedItems).toHaveLength(2); - }); - - - test("in 5, 2 and 4 is not completed", () => { - jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); - expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(2); - }); - -}); - - - - - - - - - - diff --git a/src/__tests__/201802109/todoItem.spec.js b/src/__tests__/201802109/todoItem.spec.js new file mode 100644 index 0000000..2c7921b --- /dev/null +++ b/src/__tests__/201802109/todoItem.spec.js @@ -0,0 +1,39 @@ +import TodoItem from "../../vo/TodoItem"; + +describe("할 일을 만들 수 있다.", () => { + test("todo item 생성하기", () => { + const todoItem= new TodoItem(1, '오늘은 술 먹는날'); + expect(todoItem.task).toEqual('오늘은 술 먹는날'); + }); +}); + +describe("할 일을 업데이트 할 수 있다.", () => { + test("todo item 업데이트 하기", () => { + const todoItem= new TodoItem(1, '오늘은 술 먹는날'); + todoItem.updateTask('오늘은 안 마실래'); + expect(todoItem.task).toEqual('오늘은 안 마실래'); + }); +}); + +describe("할 일을 완료로 생성할 수 있다.", () => { + test("todo item 완료로 바꾸기", () => { + const todoItem= new TodoItem(1, '오늘은 술 먹는날',new Date(), true); + expect(todoItem.completed).toBeTruthy(); + }); +}); + + +describe("할 일에 날짜가 들어간다..", () => { + test("todo item이 오늘 만들었으면, isToday가 true이다.", () => { + const sourceDate = new Date(); + const targetDate = new Date(); + const todoItem= new TodoItem(1, '오늘은 술 먹는날',sourceDate); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeTruthy(); + }); + test("어제 만들었으면 isToday가 false이다.", () => { + const sourceDate = new Date('2022-05-08T10:00:00'); + const todoItem = new TodoItem(1, '오늘은 술 먹는날',sourceDate); + const targetDate = new Date('2022-05-09T10:00:00'); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeFalsy(); + }); +}); \ No newline at end of file diff --git a/src/__tests__/201802109/todoList.spec.js b/src/__tests__/201802109/todoList.spec.js new file mode 100644 index 0000000..cf707b0 --- /dev/null +++ b/src/__tests__/201802109/todoList.spec.js @@ -0,0 +1,103 @@ +import TodoList from "../../vo/TodoList"; +import TodoItem from "../../vo/TodoItem"; + +let todoItem1, todoItem2, todoItem3, todoItem4, todoItem5; +let todoList; + +beforeEach(() => { + todoItem1 = new TodoItem(1, "할 일 1", new Date()); + todoItem2 = new TodoItem(2, "할 일 2", new Date()); + todoItem3 = new TodoItem(3, "할 일 3", new Date()); + todoItem4 = new TodoItem(4, "할 일 4", new Date()); + todoItem5 = new TodoItem(5, "할 일 5", new Date()); + let todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + todoList = new TodoList(todoItemList, new Date()); +}); + +describe("할 일 목록을 가지고 있다.", () => { + test("5개를 만들면, 5개가 있다.", () => { + expect(todoList._items).toHaveLength(5); + }); +}); + +describe("할 일 목록에서 삭제를 할 수 있다.", () => { + test("5개의 할 일이 있는데, id가 3인 할 일을 삭제할 수 있다.", () => { + todoList.removeTodoItem(3); + expect(todoList._items).toHaveLength(4); + expect(todoList._items.some((todoItem) => todoItem.id === 3)).toBeFalsy(); + }); +}); + +describe("할 일 목록에서 할 일을 추가할 수 있다.", () => { + test("5개의 할 일이 있는데, id가 6인 할 일을 추가할 수 있다.", () => { + const todoItem6 = new TodoItem(6, "할 일 6", new Date()); + + todoList.pushTodoItem(todoItem6); + expect(todoList._items).toHaveLength(6); + expect(todoList._items.some((todoItem) => todoItem.id === 6)).toBeTruthy(); + }); +}); + +describe("생성한 할 일들 중에서 오늘 할 일, 지난 할 일 구분하기.", () => { + test("5개의 할 일이 있는데, 2번 뺴고 오늘 만들 일 이다.", () => { + jest + .spyOn(todoItem2, "equalsDayOfCreatedAt") + .mockImplementation(() => false); + expect(todoList.equalsDayItems).toHaveLength(4); + expect( + todoList.equalsDayItems.some((todoItem) => todoItem.id === 2) + ).toBeFalsy(); + }); + test("5개의 할 일이 있는데, id 2번만 지난 할 일이다.", () => { + jest + .spyOn(todoItem2, "equalsDayOfCreatedAt") + .mockImplementation(() => false); + + expect(todoList.notEqualsDayItems).toHaveLength(1); + expect( + todoList.notEqualsDayItems.some((todoItem) => todoItem.id === 2) + ).toBeTruthy(); + }); +}); + +describe("오늘 할 일 중 완료/미완료 구분하기.", () => { + test("5개의 할 일이 있는데, 2번, 3번만 완료이다.", () => { + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + + expect(todoList.equalsDayAndCompletedItems).toHaveLength(2); + }); + test("5개의 할 일이 있는데, 2번, 4번만 미완료이다.", () => { + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + + expect(todoList.equalsDayAndNotCompletedItems).toHaveLength(2); + }); +}); + +describe("지난 할 일 중 완료/미완료 구분하기.", () => { + test("5개의 지난 일이 있는데, 2번, 3번만 완료이다.", () => { + jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); + + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + expect(todoList.notEqualsDayAndCompletedItems).toHaveLength(2); + }); + test("5개의 지난 일이 있는데, 2번, 4번만 미완료이다.", () => { + jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); + + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(2); + }); +}); \ No newline at end of file From cf874b66b1d43e47097a4e47d27c39c7be5dbad8 Mon Sep 17 00:00:00 2001 From: tnghwk0661 Date: Thu, 12 May 2022 15:41:59 +0900 Subject: [PATCH 07/14] Team 11 201802086 --- src/__tests__/201802086/todoItem.spec.js | 54 ++++++++++++ src/__tests__/201802086/todoList.spec.js | 104 +++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 src/__tests__/201802086/todoItem.spec.js create mode 100644 src/__tests__/201802086/todoList.spec.js diff --git a/src/__tests__/201802086/todoItem.spec.js b/src/__tests__/201802086/todoItem.spec.js new file mode 100644 index 0000000..607e46d --- /dev/null +++ b/src/__tests__/201802086/todoItem.spec.js @@ -0,0 +1,54 @@ +import TodoItem from "../../vo/TodoItem"; + +describe("create task", () => { + test("todo item create", () => { + const todoItem = new TodoItem(1, "drunk day"); + expect(todoItem.task).toEqual("drunk day"); + }); +}); + +describe("update task", () => { + test("update todo", () => { + const todoItem = new TodoItem(1, "drunk day"); + todoItem.updateTask("quit") + expect(todoItem.task).toEqual("quit"); + }); +}); + +describe("task end or not", () => { + test("task end", () => { + const todoItem = new TodoItem(1, "drunk day"); + todoItem.setComplete(); + expect(todoItem.complete).toBeTruthy; + }); + + test("task end", () => { + const todoItem = new TodoItem(1, "drunk day"); + todoItem.unsetComplete(); + expect(todoItem.complete).toBeFalsy; + }); +}); + + +describe("date in task", () => { + test("today is true", () => { + const sourceDate = new Date(); + const targetDate = new Date(); + const todoItem = new TodoItem(1, "drunk day", sourceDate); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeTruthy; + }); + test("yesterday is false", () => { + const sourceDate = new Date('2022-05-08T10:00:00'); + const targetDate = new Date('2022-05-09T10:00:00'); + const todoItem = new TodoItem(1, "drunk day", sourceDate); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeFalsy; + }); +}); + + +describe("create task with complete", () => { + test("create task with complete", () => { + const todoItem = new TodoItem(1, "drunk day", new Date(), true); + expect(todoItem.completed).toBeTruthy; + }); +}); \ No newline at end of file diff --git a/src/__tests__/201802086/todoList.spec.js b/src/__tests__/201802086/todoList.spec.js new file mode 100644 index 0000000..4fcf2fe --- /dev/null +++ b/src/__tests__/201802086/todoList.spec.js @@ -0,0 +1,104 @@ +import TodoItem from "../../vo/TodoItem"; +import TodoList from "../../vo/TodoList"; + +let todoItem1, todoItem2, todoItem3, todoItem4, todoItem5; +let todoList; + +beforeEach(() => { + todoItem1 = new TodoItem(1, "task 1", new Date()); + todoItem2 = new TodoItem(2, "task 2", new Date()); + todoItem3 = new TodoItem(3, "task 3", new Date()); + todoItem4 = new TodoItem(4, "task 4", new Date()); + todoItem5 = new TodoItem(5, "task 5", new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + todoList = new TodoList(todoItemList, new Date()); +}); + +describe("have task list", () => { + test("create 5, have 5", () => { + /*const todoItem1 = new TodoItem(1, "task 1", new Date()); + const todoItem2 = new TodoItem(2, "task 2", new Date()); + const todoItem3 = new TodoItem(3, "task 3", new Date()); + const todoItem4 = new TodoItem(4, "task 4", new Date()); + const todoItem5 = new TodoItem(5, "task 5", new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + const todoList = new TodoList(todoItemList, new Date());*/ + expect(todoList.items).toHaveLength(5); + }); +}); + + +describe("delete task", () => { + test("in 5 task, delete id is 3", () => { + todoList.removeTodoItem(3); + + expect(todoList.items).toHaveLength(4); + expect(todoList.items.some((todoItem) => todoItem.id === 3)).toBeFalsy; + }); +}); + + + +describe("add task", () => { + test("in 5 task, delete id is 3", () => { + + + const todoItem6 = new TodoItem(6, 'task 6', new Date()); + todoList.pushTodoItem(todoItem6); + expect(todoList.items).toHaveLength(6); + expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy(); + }); +}); + + + + +describe("separete today yesterday", () => { + test("5 tasks is today", () => { + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + + expect(todoList.equalsDayItems).toHaveLength(4); + expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy; + }); + + + test("todoId 2 is yesterday task", () => { + + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + + expect(todoList.notEqualsDayItems).toHaveLength(1); + expect(todoList.notEqualsDayItems.some((todoItem) => todoItem.id === 2)).toBeFalsy; + }); + +}); + + + + + +describe("separete complete or not", () => { + test("in 5, 2 and 3 is complete", () => { + jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + expect(todoList.notEqualsDayAndCompletedItems).toHaveLength(2); + }); + + + test("in 5, 2 and 4 is not completed", () => { + jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(2); + }); + +}); \ No newline at end of file From 87cfb0e1a085447f9c173dd2ae46ea58f5c2560c Mon Sep 17 00:00:00 2001 From: tnghwk0661 Date: Sat, 14 May 2022 16:15:01 +0900 Subject: [PATCH 08/14] 201802054 assignment 2 --- src/__tests__/201802054/todoItem.spec.js | 51 ++++++++++++ src/__tests__/201802054/todoList.spec.js | 100 +++++++++++++++++++++++ src/vo/TodoList.js | 4 + 3 files changed, 155 insertions(+) create mode 100644 src/__tests__/201802054/todoItem.spec.js create mode 100644 src/__tests__/201802054/todoList.spec.js diff --git a/src/__tests__/201802054/todoItem.spec.js b/src/__tests__/201802054/todoItem.spec.js new file mode 100644 index 0000000..f72edb6 --- /dev/null +++ b/src/__tests__/201802054/todoItem.spec.js @@ -0,0 +1,51 @@ +import TodoItem from "../../vo/TodoItem"; + +describe("할 일을 만들 수 있다.", () => { + test("todo item 생성하기", () => { + const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); + expect(todoItem.task).toEqual('오늘은 술 먹는 날'); + }); +}); + +describe("할 일을 업데이트 할 수 있다.", () => { + test("todo item 업데이트 하기", () => { + const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); + todoItem.updateTask('오늘은 그냥 안 마실래'); + expect(todoItem.task).toEqual('오늘은 그냥 안 마실래'); + }); +}); + +describe("할 일을 완료/미완료로 바꿀 수 있다.", () => { + test("todo item 완료로 바꾸기", () => { + const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); + todoItem.setComplete(); + expect(todoItem.completed).toBeTruthy(); + }); + test("todo item 미완료로 바꾸기", () => { + const todoItem = new TodoItem(1, '오늘은 술 먹는 날'); + todoItem.unsetComplete(); + expect(todoItem.completed).toBeFalsy(); + }); +}); + +describe("할 일에 날짜가 들어간다.", () => { + test("todo item이 오늘 만들었으면, isToday가 true이다.", () => { + const sourceDate = new Date(); + const targetDate = new Date(); + const todoItem = new TodoItem(1, '오늘은 술 먹는 날', sourceDate); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeTruthy(); + }); + test("todo item이 어제 만들었으면, isToday가 false이다.", () => { + const sourceDate = new Date('2022-05-08T10:00:00'); + const targetDate = new Date('2022-05-09T10:00:00'); + const todoItem = new TodoItem(1, '오늘은 술 먹는 날', sourceDate); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeFalsy(); + }); +}); + +describe("할 일을 완료로 바꿀 수 있다.", () => { + test("todo item 완료로 바꾸기", () => { + const todoItem = new TodoItem(1, '오늘은 술 먹는 날', new Date(), true); + expect(todoItem.completed).toBeTruthy(); + }); +}); diff --git a/src/__tests__/201802054/todoList.spec.js b/src/__tests__/201802054/todoList.spec.js new file mode 100644 index 0000000..967adde --- /dev/null +++ b/src/__tests__/201802054/todoList.spec.js @@ -0,0 +1,100 @@ +import TodoItem from "../../vo/TodoItem"; +import TodoList from "../../vo/TodoList"; + +let todoItem1, todoItem2, todoItem3, todoItem4, todoItem5; +let todoList; + +beforeEach(() => { + todoItem1 = new TodoItem(1, '할 일 1', new Date()); + todoItem2 = new TodoItem(2, '할 일 2', new Date()); + todoItem3 = new TodoItem(3, '할 일 3', new Date()); + todoItem4 = new TodoItem(4, '할 일 4', new Date()); + todoItem5 = new TodoItem(5, '할 일 5', new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5] + todoList = new TodoList(todoItemList, new Date()); +}); + +describe("할 일 목록을 가지고 있다.", () => { + test("5개를 만들면, 5개가 있다.", () => { + expect(todoList.items).toHaveLength(5); + }); +}); + +describe("할 일 목록에서 삭제를 할 수 있다..", () => { + test("5개를 만들면, id가 3인 할 일을 삭제할 수 있다.", () => { + todoList.removeTodoItem(3); + + expect(todoList.items).toHaveLength(4); + expect(todoList.items.some((todoItem) => todoItem.id === 3)).toBeFalsy(); + }); +}); + +describe("할 일 목록에서 할 일을 추가 할 수 있다..", () => { + test("5개를 만들고, id가 6인 할 일을 추기할 수 있다.", () => { + const todoItem6 = new TodoItem(6, '할 일', new Date()); + todoList.pushTodoItem(todoItem6); + + expect(todoList.items).toHaveLength(6); + expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy(); + }); +}); + +describe("생성한 할 일들 중에서 오늘 할 일, 지난 할 일 구분하기", () => { + test("5개를 할 일이 있는데, 2번 빼고 오늘 만들 일이다.", () => { + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + + expect(todoList.equalsDayItems).toHaveLength(4); + expect(todoList.equalsDayItems.some((todoItem) => todoItem.id === 2)).toBeFalsy(); + }); + test("5개를 할 일이 있는데, id 2번만 지난 할 일이다.", () => { + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + + expect(todoList.notEqualsDayItems).toHaveLength(1); + expect(todoList.notEqualsDayItems.some((todoItem) => todoItem.id === 2)).toBeTruthy(); + }); +}); + +describe("오늘 할 일 중 완료/미완료 구분하기", () => { + test("5개의 할 일이 있는데, 2번, 3번만 완료다.", () => { + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + + expect(todoList.equalsDayAndCompletedItems).toHaveLength(2); + }); + + test("5개의 할 일이 있는데, 2번, 4번만 미완료다.", () => { + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + + expect(todoList.equalsDayAndNotCompletedItems).toHaveLength(2); + }); + +}); + +describe("지난 할 일 중 완료/미완료 구분하기", () => { + test("5개의 지난 할 일이 있는데, 2번, 3번만 완료다.", () => { + jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + + expect(todoList.notEqualsDayAndCompletedItems).toHaveLength(2); + }); + + test("5개의 지난 할 일이 있는데, 2번, 4번만 미완료다.", () => { + jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + + expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(2); + }); +}); \ No newline at end of file diff --git a/src/vo/TodoList.js b/src/vo/TodoList.js index 748775d..f4a7424 100644 --- a/src/vo/TodoList.js +++ b/src/vo/TodoList.js @@ -47,6 +47,10 @@ class TodoList { return this.notEqualsDayItems.filter(this._notCompletedFilter); } + get items() { + return this._items; + } + pushTodoItem = (todoItem) => { this._items.push(todoItem); }; From d8e1a44a025cf32e5cd403d1ab44d22235d1e6f0 Mon Sep 17 00:00:00 2001 From: "ldw3097\\ldw30" Date: Sun, 15 May 2022 20:27:01 +0900 Subject: [PATCH 09/14] =?UTF-8?q?=EC=BB=A4=EB=B0=8B=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/todoItem.spec.js | 45 +++++++++++++++++++-- src/__tests__/todoList.spec.js | 72 ++++++++++++++++++++++++++++++++-- src/vo/TodoItem.js | 23 ++++++++++- src/vo/TodoList.js | 48 ++++++++++++++++++++++- 4 files changed, 180 insertions(+), 8 deletions(-) diff --git a/src/__tests__/todoItem.spec.js b/src/__tests__/todoItem.spec.js index decc062..7bc2e2f 100644 --- a/src/__tests__/todoItem.spec.js +++ b/src/__tests__/todoItem.spec.js @@ -1,7 +1,46 @@ import TodoItem from "../vo/TodoItem"; -describe("테스트 그룹", () => { - test("테스트", () => { - expect(0).toEqual(0); +describe("할 일을 만들수 있다", () => { + test("todo 아이템 생성하기", () => { + const todoItem = new TodoItem(1, "오늘은 술먹는날"); + expect(todoItem.task).toEqual("오늘은 술먹는날"); + }); +}); + +describe("할 일을 업데이트 할 수 있다.", () => { + test("todo 아이템 업데이트하기", () => { + const todoItem = new TodoItem(1, "오늘은 술먹는날"); + todoItem.updateTask('오늘은 그냥 안마실래'); + expect(todoItem.task).toEqual("오늘은 그냥 안마실래"); + }); +}); + +describe("할 일을 완료/미완료로 바꿀 수 있다.", () => { + test("todo 아이템 완료로 바꾸기", () => { + const todoItem = new TodoItem(1, "오늘은 술먹는날"); + todoItem.setComplete(); + expect(todoItem.completed).toBeTruthy; + }); + + test("todo 아이템 미완료로 바꾸기", () => { + const todoItem = new TodoItem(1, "오늘은 술먹는날"); + todoItem.unsetComplete(); + expect(todoItem.completed).toBeFalsy(); + }); +}); + +describe("할일에 날짜가 들어간다.", () => { + test("todo item이 오늘 만들었으면, isToday가 true이다", () => { + const sourceDate = new Date(); + const targetDate = new Date(); + const todoItem = new TodoItem(1, "오늘은 술먹는날", sourceDate); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeTruthy(); + + }); + test("todo item이 어제 만들었으면, isToday가 false이다", () => { + const sourceDate = new Date('2022-05-08T10:00:00'); + const todoItem = new TodoItem(1, "오늘은 술먹는날", sourceDate); + const targetDate = new Date(Date.now()); + expect(todoItem.equalsDayOfCreatedAt(targetDate)).toBeFalsy(); }); }); \ No newline at end of file diff --git a/src/__tests__/todoList.spec.js b/src/__tests__/todoList.spec.js index 17d1d5b..17e1df7 100644 --- a/src/__tests__/todoList.spec.js +++ b/src/__tests__/todoList.spec.js @@ -1,8 +1,74 @@ import TodoItem from "../vo/TodoItem"; import TodoList from "../vo/TodoList"; +let todoItem1, todoItem2, todoItem3, todoItem4, todoItem5; +let todoList; -describe("테스트 그룹", () => { - test("테스트", () => { - expect(0).toEqual(0); +beforeEach(() => { + todoItem1 = new TodoItem(1, "할 일 1", new Date()); + todoItem2 = new TodoItem(2, "할 일 2", new Date()); + todoItem3 = new TodoItem(3, "할 일 3", new Date()); + todoItem4 = new TodoItem(4, "할 일 4", new Date()); + todoItem5 = new TodoItem(5, "할 일 5", new Date()); + const todoItemList = [todoItem1, todoItem2, todoItem3, todoItem4, todoItem5]; + todoList = new TodoList(todoItemList, new Date()); +}); + +describe("할일 목록을 가지고 있다.", () => { + test("5개를 만들면 5개가 있다.", () => { + expect(todoList.items).toHaveLength(5); + }); +}); + +describe("할일 목록에서 삭제를 할수 있다..", () => { + test("5개의 할일이 있는데, id가 3인 할일을 삭제할 수 있다.", () => { + todoList.removeTodoItem(3); + expect(todoList.items).toHaveLength(4); + expect(todoList.items.some((todoItem) => todoItem.id === 3)).toBeFalsy(); + }); +}); + +describe("할일 목록에서 할일을 추가 할수 있다..", () => { + test("5개의 할일이 있는데, id가 6인 할일을 추가할 수 있다.", () => { + const todoItem6 = new TodoItem(6, "할 일 6", new Date()); + todoList.pushTodoItem(todoItem6); + expect(todoList.items).toHaveLength(6); + expect(todoList.items.some((todoItem) => todoItem.id === 6)).toBeTruthy(); + }); +}); + +describe("생성한 할 일들 중에서 오늘 할 일, 지난 할 일 구분하기", () => { + test("5개의 할 일이 있는데, 모두 오늘 만들 일이다.", () => { + jest + .spyOn(todoItem2, "equalsDayOfCreatedAt") + .mockImplementation(() => false); + + expect(todoList.equalsDayItems).toHaveLength(4); + expect( + todoList.equalsDayItems.some((todoItem) => todoItem.id === 2) + ).toBeFalsy(); + }); + + test("5개의 할 일이 있는데, id 2번만 지난 할일이다.", () => { + jest + .spyOn(todoItem2, "equalsDayOfCreatedAt") + .mockImplementation(() => false); + + expect(todoList.equalsDayItems).toHaveLength(4); + expect( + todoList.equalsDayItems.some((todoItem) => todoItem.id === 2) + ).toBeFalsy(); + }); +}); + +describe("오늘 할일중 완료/미완료 구분하기", () => { + test("5개의 할일이 있는데, 2번 3번만 완료다.", () => { + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + expect(todoList.equalsDayAndCompletedItems).toHaveLength(2); + }); + test("5개의 할일이 있는데, 2번 4번만 미완료다.", () => { + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(false); + jest.spyOn(todoItem4, "completed", "get").mockReturnValue(false); + expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(5); }); }); diff --git a/src/vo/TodoItem.js b/src/vo/TodoItem.js index 2ac7088..c220201 100644 --- a/src/vo/TodoItem.js +++ b/src/vo/TodoItem.js @@ -12,11 +12,32 @@ class TodoItem { _createdAt = ""; _completed = false; - constructor() { + constructor(id, task, createdAt, completed) { makeObservable(this, { _task: observable, _completed: observable, }); + this._id = id; + this._task = task; + this._createdAt = createdAt; + this._completed = completed; + } + + updateTask = (task) => { + this._task = task; + } + + setComplete = () =>{ + this._completed = true; + } + unsetComplete = () =>{ + this._completed = false; + } + + equalsDayOfCreatedAt = (_targetDate) =>{ + const sourceDate = new Date(this._createdAt).setHours(0,0,0,0); + const targetDate = new Date(_targetDate).setHours(0,0,0,0); + return sourceDate === targetDate; } get id() { diff --git a/src/vo/TodoList.js b/src/vo/TodoList.js index 2685d97..ed98071 100644 --- a/src/vo/TodoList.js +++ b/src/vo/TodoList.js @@ -8,11 +8,57 @@ class TodoList { _items = []; _date = ""; - constructor() { + constructor(items, date) { makeObservable(this, { _items: observable, }); + this._items = items; + this._date = date; } + + + get items() { + return this._items; + } + + removeTodoItem = (todoId) => { + const targetTodoItemIndex = this._items.findIndex( + (todo) => todo.id === todoId + ); + if (targetTodoItemIndex === -1) return; + this._items.splice(targetTodoItemIndex, 1); + }; + + pushTodoItem = (todoItem) => { + this._items.push(todoItem); + } + + _equalsDayFilter = (todoItem) => todoItem.equalsDayOfCreatedAt(this._date); + _notEqualsDayFilter = (todoItem) => !todoItem.equalsDayOfCreatedAt(this._date); + + _completedFilter = (todoItem) => todoItem.completed; + _notCompletedFilter = (todoItem) => !todoItem.completed; + + + + get equalsDayItems() { + return this._items.filter(this._equalsDayFilter); + } + get notEqualsDayItems() { + return this._items.filter(this._notEqualsDayFilter); + } + + get equalsDayAndCompletedItems() { + return this.equalsDayItems.filter(this._completedFilter); + } + + get notEqualsDayAndNotCompletedItems() { + return this.equalsDayItems.filter(this._notCompletedFilter); + } + + get notEqualsDayItems() { + return this._items.filter(this._notEqualsDayFilter); + } } export default TodoList; From 567f8dee57710143ea871a953159813db2f0cdc8 Mon Sep 17 00:00:00 2001 From: "ldw3097\\ldw30" Date: Sun, 15 May 2022 20:30:21 +0900 Subject: [PATCH 10/14] =?UTF-8?q?=EC=BB=A4=EB=B0=8B=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/{ => 201802123}/todoItem.spec.js | 0 src/__tests__/{ => 201802123}/todoList.spec.js | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/__tests__/{ => 201802123}/todoItem.spec.js (100%) rename src/__tests__/{ => 201802123}/todoList.spec.js (100%) diff --git a/src/__tests__/todoItem.spec.js b/src/__tests__/201802123/todoItem.spec.js similarity index 100% rename from src/__tests__/todoItem.spec.js rename to src/__tests__/201802123/todoItem.spec.js diff --git a/src/__tests__/todoList.spec.js b/src/__tests__/201802123/todoList.spec.js similarity index 100% rename from src/__tests__/todoList.spec.js rename to src/__tests__/201802123/todoList.spec.js From 6242c62f4efe84db529d6ed422d24fff8273a42f Mon Sep 17 00:00:00 2001 From: "ldw3097\\ldw30" Date: Sun, 15 May 2022 20:33:32 +0900 Subject: [PATCH 11/14] =?UTF-8?q?=EC=BB=A4=EB=B0=8B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/201802123/todoItem.spec.js | 2 +- src/__tests__/201802123/todoList.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/__tests__/201802123/todoItem.spec.js b/src/__tests__/201802123/todoItem.spec.js index 7bc2e2f..bf2957c 100644 --- a/src/__tests__/201802123/todoItem.spec.js +++ b/src/__tests__/201802123/todoItem.spec.js @@ -1,4 +1,4 @@ -import TodoItem from "../vo/TodoItem"; +import TodoItem from "../../vo/TodoItem"; describe("할 일을 만들수 있다", () => { test("todo 아이템 생성하기", () => { diff --git a/src/__tests__/201802123/todoList.spec.js b/src/__tests__/201802123/todoList.spec.js index 17e1df7..bdd64fc 100644 --- a/src/__tests__/201802123/todoList.spec.js +++ b/src/__tests__/201802123/todoList.spec.js @@ -1,5 +1,5 @@ -import TodoItem from "../vo/TodoItem"; -import TodoList from "../vo/TodoList"; +import TodoItem from "../../vo/TodoItem"; +import TodoList from "../../vo/TodoList"; let todoItem1, todoItem2, todoItem3, todoItem4, todoItem5; let todoList; From 4c36e299547a0735a6633cee81ea5ec8ecf31a62 Mon Sep 17 00:00:00 2001 From: "ldw3097\\ldw30" Date: Sun, 15 May 2022 20:45:56 +0900 Subject: [PATCH 12/14] =?UTF-8?q?=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/201802123/todoList.spec.js | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/__tests__/201802123/todoList.spec.js b/src/__tests__/201802123/todoList.spec.js index bdd64fc..070d9c6 100644 --- a/src/__tests__/201802123/todoList.spec.js +++ b/src/__tests__/201802123/todoList.spec.js @@ -67,8 +67,38 @@ describe("오늘 할일중 완료/미완료 구분하기", () => { expect(todoList.equalsDayAndCompletedItems).toHaveLength(2); }); test("5개의 할일이 있는데, 2번 4번만 미완료다.", () => { + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(true); jest.spyOn(todoItem2, "completed", "get").mockReturnValue(false); jest.spyOn(todoItem4, "completed", "get").mockReturnValue(false); - expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(5); + expect(todoList.equalsDayAndNotCompletedItems).toHaveLength(2); + }); +}); + +describe("지난 할 일 중 완료/미완료 구분하기", () => { + test("5개의 지난 할 일이 있는데, 2번, 3번만 완료다.", () => { + jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + + expect(todoList.notEqualsDayAndCompletedItems).toHaveLength(2); + }); + + test("5개의 지난 할 일이 있는데, 2번, 4번만 미완료다.", () => { + jest.spyOn(todoItem1, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem2, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + + expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(2); }); }); From c7abcf196fe973b3abd2d62f2cd35d926a10635e Mon Sep 17 00:00:00 2001 From: tnghwk0661 Date: Sat, 21 May 2022 13:36:45 +0900 Subject: [PATCH 13/14] change the file --- src/__tests__/201802054/todoList.spec.js | 20 ++++++++++---------- src/__tests__/201802109/todoList.spec.js | 20 ++++++++++---------- src/__tests__/201802123/todoList.spec.js | 10 +++++----- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/__tests__/201802054/todoList.spec.js b/src/__tests__/201802054/todoList.spec.js index 967adde..fb74f6c 100644 --- a/src/__tests__/201802054/todoList.spec.js +++ b/src/__tests__/201802054/todoList.spec.js @@ -56,16 +56,16 @@ describe("생성한 할 일들 중에서 오늘 할 일, 지난 할 일 구분 describe("오늘 할 일 중 완료/미완료 구분하기", () => { test("5개의 할 일이 있는데, 2번, 3번만 완료다.", () => { - jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); expect(todoList.equalsDayAndCompletedItems).toHaveLength(2); }); test("5개의 할 일이 있는데, 2번, 4번만 미완료다.", () => { - jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(true); expect(todoList.equalsDayAndNotCompletedItems).toHaveLength(2); }); @@ -79,8 +79,8 @@ describe("지난 할 일 중 완료/미완료 구분하기", () => { jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); expect(todoList.notEqualsDayAndCompletedItems).toHaveLength(2); }); @@ -91,9 +91,9 @@ describe("지난 할 일 중 완료/미완료 구분하기", () => { jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(true); expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(2); }); diff --git a/src/__tests__/201802109/todoList.spec.js b/src/__tests__/201802109/todoList.spec.js index cf707b0..70266db 100644 --- a/src/__tests__/201802109/todoList.spec.js +++ b/src/__tests__/201802109/todoList.spec.js @@ -62,15 +62,15 @@ describe("생성한 할 일들 중에서 오늘 할 일, 지난 할 일 구분 describe("오늘 할 일 중 완료/미완료 구분하기.", () => { test("5개의 할 일이 있는데, 2번, 3번만 완료이다.", () => { - jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); expect(todoList.equalsDayAndCompletedItems).toHaveLength(2); }); test("5개의 할 일이 있는데, 2번, 4번만 미완료이다.", () => { - jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(true); expect(todoList.equalsDayAndNotCompletedItems).toHaveLength(2); }); @@ -84,8 +84,8 @@ describe("지난 할 일 중 완료/미완료 구분하기.", () => { jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); expect(todoList.notEqualsDayAndCompletedItems).toHaveLength(2); }); test("5개의 지난 일이 있는데, 2번, 4번만 미완료이다.", () => { @@ -95,9 +95,9 @@ describe("지난 할 일 중 완료/미완료 구분하기.", () => { jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(true); expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(2); }); }); \ No newline at end of file diff --git a/src/__tests__/201802123/todoList.spec.js b/src/__tests__/201802123/todoList.spec.js index 070d9c6..8ccfa2a 100644 --- a/src/__tests__/201802123/todoList.spec.js +++ b/src/__tests__/201802123/todoList.spec.js @@ -83,8 +83,8 @@ describe("지난 할 일 중 완료/미완료 구분하기", () => { jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); expect(todoList.notEqualsDayAndCompletedItems).toHaveLength(2); }); @@ -95,9 +95,9 @@ describe("지난 할 일 중 완료/미완료 구분하기", () => { jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(true); expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(2); }); From b02788b9b156ee95c95436fc0ba8654b2b2a2ac6 Mon Sep 17 00:00:00 2001 From: Hmmm Date: Sat, 21 May 2022 13:38:47 +0900 Subject: [PATCH 14/14] Update todoList.spec.js change the file --- src/__tests__/201802086/todoList.spec.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/__tests__/201802086/todoList.spec.js b/src/__tests__/201802086/todoList.spec.js index 4fcf2fe..7b23af0 100644 --- a/src/__tests__/201802086/todoList.spec.js +++ b/src/__tests__/201802086/todoList.spec.js @@ -83,8 +83,8 @@ describe("separete complete or not", () => { jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem2, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem2, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); expect(todoList.notEqualsDayAndCompletedItems).toHaveLength(2); }); @@ -95,10 +95,10 @@ describe("separete complete or not", () => { jest.spyOn(todoItem3, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem4, "equalsDayOfCreatedAt").mockImplementation(() => false); jest.spyOn(todoItem5, "equalsDayOfCreatedAt").mockImplementation(() => false); - jest.spyOn(todoItem1, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem3, "completed", "get").mockReturnValue(() => true); - jest.spyOn(todoItem5, "completed", "get").mockReturnValue(() => true); + jest.spyOn(todoItem1, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem3, "completed", "get").mockReturnValue(true); + jest.spyOn(todoItem5, "completed", "get").mockReturnValue(true); expect(todoList.notEqualsDayAndNotCompletedItems).toHaveLength(2); }); -}); \ No newline at end of file +});