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

[숫자야구 미션 다시 풀어보기 리뷰] 박건우 리뷰용 PR입니다. #766

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
70aa758
chore(format): integrate Prettier, configure ESLint
pigpgw Feb 2, 2024
3ec14b8
docs: 기능 목록 README 작성
pigpgw Feb 2, 2024
54c23d3
add: Car.js
pigpgw Feb 2, 2024
d9c7b64
feat: add Validator.js
pigpgw Feb 2, 2024
21b1411
add: tryAdvance fnc in Car.js
pigpgw Feb 2, 2024
f7d304a
add: getDistance for judge winner
pigpgw Feb 2, 2024
f0436e4
add: apply validator in getUserNames
pigpgw Feb 2, 2024
e6465e8
feat: to set up cars with the names entered
pigpgw Feb 3, 2024
dabb045
refactor: Separate car setup into two functions
pigpgw Feb 3, 2024
633f363
docs: UPDATE README.md
pigpgw Feb 3, 2024
a1770f0
feat: getTryAdvanceCount fnc
pigpgw Feb 3, 2024
3f5dcd1
test: exTest.js 테스트 코드 추가
pigpgw Feb 3, 2024
280c146
feat: 차들 입력시 입력한 차 이름들 출력 기능
pigpgw Feb 3, 2024
7f52177
feat: 사용자가 입력한 횟수만큼 전진 시도 기능
pigpgw Feb 3, 2024
d89f667
feat: 최종 우승 판결 기능 구현 및 테스트코드 통과
pigpgw Feb 3, 2024
91575e6
Update: README.md
pigpgw Feb 3, 2024
6232299
refactor: Separate car creation logic into award function
pigpgw Feb 3, 2024
fe9294e
game message.js add static
pigpgw Feb 3, 2024
a9cf93c
refactor: separate inputOutput fnc in App Class
pigpgw Feb 3, 2024
f2485de
refactor: separate RaceSimulator in App Class
pigpgw Feb 3, 2024
3dd7175
chore: unnecessary code delete
pigpgw Feb 3, 2024
8c8dab4
chore: eslintrc(airbnb), prettier 미적용 문제 해결
pigpgw Feb 4, 2024
1fcff4e
chore: delete constant.js
pigpgw Feb 4, 2024
756c309
InputOutput.js의 INPUT ERROR 메세지 GAME MESSAGE로 분리
pigpgw Feb 4, 2024
168f947
Refactor: Replace direct Console.print() with this.inputOutput.print(…
pigpgw Feb 4, 2024
f736f3d
최종 제출
pigpgw Feb 4, 2024
04f2d50
test 코드 연습
pigpgw Feb 4, 2024
7437495
refactor: random number to masic number
pigpgw Feb 14, 2024
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
12 changes: 12 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends:['airbnb','prettier/react', 'eslint:recommended','plugin:prettier/recommended'],
rules:{
'react/jsx-filename-extension':
['error', { 'extensions': [".js", ".jsx"] }],
}
};
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"semi": true,
"useTabs": false,
"tabWidth": 2,
"trailingComma": "all",
"printWidth": 80,
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "auto"
}
56 changes: 56 additions & 0 deletions __tests__/exTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import Car from "../src/Car";
import App from "../src/App";

describe("문자열 테스트", () => {
test("Test the entered car name", () => {
const carNameList = "pobi,woni,jun";
const result = carNameList.split(",");
expect(result).toEqual(["pobi", "woni", "jun"]);
});

test("자동차 전진 체크", () => {
const car = new Car("car");
car.tryAdvance();
car.tryAdvance();
car.tryAdvance();
car.tryAdvance();
car.tryAdvance();
car.tryAdvance();
car.tryAdvance();
console.log(car.getMovedDistance());
expect(car.getMovedDistance()).toEqual(expect.stringMatching(/^-+$/));
});

test("자동차 이름 에외 처리 테스트", () => {
const app = new App();
const carNameList = ["pobiwoni", "jun"];
expect(() => app.makingCar(carNameList)).toThrow("[ERROR]");
});

test("자동차 이름 에외 처리 테스트", () => {
const app = new App();
const carNameList = [" ", "jun"];
expect(() => app.makingCar(carNameList)).toThrow("[ERROR]");
});

test("자동차 이름 에외 처리 테스트", () => {
const app = new App();
const carNameList = ["1234", "jun"];
expect(() => app.makingCar(carNameList)).toThrow("[ERROR]");
});

test("자동차 이름 에외 처리 테스트", () => {
const app = new App();
const carNameList = [""];
expect(() => app.makingCar(carNameList)).toThrow("[ERROR]");
});

// toBe는 배열이나 객체에서의 참조가 동일한지 확인함, 하지만 split처럼 배열이나 객체의 내용을 비교하라면
// toEqual 또는 toStrictEqual을 사용해야 한다.
test('Splitting "1,2" should result in an array [1, 2]', () => {
const inputString = "1,2";
const resultArray = inputString.split(",");

expect(resultArray).toEqual(["1", "2"]);
});
});
12 changes: 12 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## 기능 목록
- [x] 경주할 자동차 이름을 입력받는 기능 (이름은 쉼표(,) 기준으로 구분)
- [x] 입력한 자동차 이름들 값이 입력 조건에 유효한 값인지 확인하는 기능
- [x] 쉼표를 기준으로 5자리 이하인지 체크하는 기능
- [x] 몇번의 이동 시도를 할 것인지 물어보는 메세지를 출력하는 기능
- [x] 입력한 이동 시도 값을 검증하는 기능
- [x] 숫자인지 체크하는 기능
- [x] 랜덤값을 생성하는 기능
- [x] 랜덤값에 따른 전진 판별 기능
- [x] 매번의 이동 시도 직후 결과를 출력하는 기능
- [x] 우승자를 판별하는 기능
- [x] 우승자를 출력하는 기능
Loading