Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team 11/assignment #15

Open
wants to merge 19 commits into
base: team-11
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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}"
}
]
}
51 changes: 51 additions & 0 deletions src/__tests__/201802054/todoItem.spec.js
Original file line number Diff line number Diff line change
@@ -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();
});
});
100 changes: 100 additions & 0 deletions src/__tests__/201802054/todoList.spec.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
54 changes: 54 additions & 0 deletions src/__tests__/201802086/todoItem.spec.js
Original file line number Diff line number Diff line change
@@ -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;
});
});
104 changes: 104 additions & 0 deletions src/__tests__/201802086/todoList.spec.js
Original file line number Diff line number Diff line change
@@ -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);
});

});
39 changes: 39 additions & 0 deletions src/__tests__/201802109/todoItem.spec.js
Original file line number Diff line number Diff line change
@@ -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();
});
});
Loading