-
Notifications
You must be signed in to change notification settings - Fork 8
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
[정찬욱] 자동차 경주 미션 Step2 #11
Open
seeyoujeong
wants to merge
41
commits into
fe-clean-code-study:seeyoujeong
Choose a base branch
from
seeyoujeong:main
base: seeyoujeong
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
5cb3142
refactor: ready 메서드 삭제하고 start 메서드에 통합
seeyoujeong f590336
test: ready 메서드 관련 테스트 코드 삭제하고 start 메서드 관련 테스트 코드로 수정
seeyoujeong ed91faf
test: 레이서 등록 관련 테스트 코드 추가
seeyoujeong 4bf618e
test: 기존 테스트 가독성 개선
seeyoujeong d258028
feat: move 메서드에 distance 매개변수 추가
seeyoujeong f282f87
test: move 메서드 관련 테스트 코드 추가
seeyoujeong 6c2170b
feat: RacerRegistry 클래스에 selectEntityType 메서드 추가 및 적용
seeyoujeong b39b88e
test: 불필요한 테스트 코드 제거
seeyoujeong 342c447
feat: RacerRegistry 클래스의 분리 문자 설정 기능 삭제
seeyoujeong ab0775d
test: 분리 문자 관련 테스트 코드 삭제
seeyoujeong e2b4400
feat: 입력 값에 trim 적용
seeyoujeong 524745b
feat: 잘못된 유형의 번호를 입력할 경우, 다시 입력 가능하게 수정
seeyoujeong 9915593
refactor: InputManager 클래스에 retryScan 메서드 추가 및 적용
seeyoujeong cb0bb7a
refactor: retryScan 메서드 파라미터 수정
seeyoujeong 2ae9e1f
refactor: Car 클래스를 Racer 클래스로 통합하고 적용
seeyoujeong 297c600
test: Car 클래스 테스트 파일 삭제 및 테스트 코드 수정
seeyoujeong be47080
refactor: 수정된 retryScan 메서드에 맞게 수정
seeyoujeong 04fde6d
fix: 삭제한 Car 클래스 export하는 코드 삭제
seeyoujeong 6e9bafe
fix: Racer 이름에 trim 적용
seeyoujeong 37e3e4e
test: 유형 선택 관련 테스트 코드 추가
seeyoujeong aa06869
feat: 레이스의 횟수 입력 받는 기능 임시 구현
seeyoujeong 31ea4d9
refactor: RaceEntry로 클래스명 수정
seeyoujeong a943909
refactor: registerRacers로 메서드명 수정
seeyoujeong b4dc967
refactor: 레이스 횟수 관련 코드 setRaceLaps 메서드로 이동하고 적용
seeyoujeong 2e9ddf9
refactor: validateTypeNumber 메서드 수정
seeyoujeong af4cb06
refactor: progressRacePerLap 메서드 추가 및 적용
seeyoujeong ed589ea
refactor: 경주 규칙을 할당할 수 있게 임시 구현
seeyoujeong 157f033
refactor: 불필요한 코드 삭제
seeyoujeong 1817aee
test: 불필요한 테스트 코드 삭제
seeyoujeong 6307358
refactor: retryScan 메서드에서 불필요한 코드 삭제하고 반영
seeyoujeong 90f13b2
test: retryScan 메서드 수정으로인한 테스트 코드 수정
seeyoujeong 5b9d698
refactor: 기본 경주 관련 프로퍼티 추가
seeyoujeong 5820cac
feat: Validator 클래스 추가
seeyoujeong 7511a8a
refactor: 유효성 검사 관련 코드 수정
seeyoujeong 02d771e
feat: 경기 규칙에 관한 유효성 검사 추가
seeyoujeong da98550
refactor: 정적 메서드 type을 추가하고 중복 제거
seeyoujeong 2adfb5e
refactor: 에러 메시지 수정
seeyoujeong 9e6c808
test: 에러 메시지 수정으로 인한 테스트 코드 수정
seeyoujeong 609e90e
test: 레이스 규칙 관련 테스트 코드 추가
seeyoujeong b127b7d
test: 유형 선택과 레이스 횟수 설정 관련 테스트 추가
seeyoujeong bb1d975
refactor: 정수 검사 조건 수정
seeyoujeong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { describe, expect, test, vi } from "vitest"; | ||
import { Race, RaceEntry } from "../domain/index.js"; | ||
import { inputManager } from "../service/index.js"; | ||
|
||
vi.mock("../service/index.js"); | ||
|
||
function retryScanMock(inputValue) { | ||
inputManager.retryScan.mockImplementationOnce(async (_, processFn) => { | ||
return processFn(inputValue); | ||
}); | ||
} | ||
|
||
describe("RaceEntry 클래스 테스트", () => { | ||
test("올바른 유형을 선택하지 않으면 오류가 발생한다.", async () => { | ||
retryScanMock("5"); | ||
|
||
const register = new RaceEntry(); | ||
|
||
await expect(register.selectEntityType()).rejects.toThrowError( | ||
"올바른 유형의 번호가 아닙니다." | ||
); | ||
}); | ||
|
||
test("올바른 유형을 선택하면 오류가 발생하지 않는다.", async () => { | ||
retryScanMock("1"); | ||
|
||
const register = new RaceEntry(); | ||
|
||
await expect(register.selectEntityType()).resolves.not.toThrowError(); | ||
}); | ||
|
||
test("레이스 횟수로 정수가 아닌 값을 입력하면 오류가 발생한다.", async () => { | ||
retryScanMock("a"); | ||
|
||
const register = new RaceEntry(); | ||
|
||
await expect(register.setRaceLaps()).rejects.toThrowError( | ||
"시도할 횟수로 정수를 입력해야 합니다." | ||
); | ||
}); | ||
|
||
test("레이스 횟수로 0이하를 입력하면 오류가 발생한다.", async () => { | ||
retryScanMock("0"); | ||
|
||
const register = new RaceEntry(); | ||
|
||
await expect(register.setRaceLaps()).rejects.toThrowError( | ||
"시도할 횟수는 1이상이어야 합니다." | ||
); | ||
}); | ||
|
||
test("레이스 횟수로 1이상을 입력하면 오류가 발생하지 않는다.", async () => { | ||
retryScanMock("1"); | ||
|
||
const register = new RaceEntry(); | ||
|
||
await expect(register.setRaceLaps()).resolves.not.toThrowError(); | ||
}); | ||
|
||
test("레이스 횟수를 설정하면 Race 클래스 인스턴스를 반환받는다.", async () => { | ||
retryScanMock("1"); | ||
const register = new RaceEntry(); | ||
|
||
const race = await register.setRaceLaps(); | ||
|
||
expect(race).toEqual(new Race(1)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
추후에 유형이 늘어날 경우를 대비하기 위해선 어떻게 해야할까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 코드가 아니었다면 유형이 늘어날 경우를 대비해서 상수로 빼거나 했을 것 같습니다.
하지만 테스트 코드이기 때문에, 가장 예외가 없고 확실한 방법인 하드 코딩을 선택했습니다!