-
Notifications
You must be signed in to change notification settings - Fork 38
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
[1단계 - 자판기] 병민(윤병인) 미션 제출합니다. #40
Merged
+18,406
−7,023
Merged
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
3d96d4c
:truck: chore(setup): 커밋 린트 설정
airman5573 9b4b681
:truck: chore(setup): webpack설정
airman5573 3271886
:truck: chore(setup): lint와 formatter설정
airman5573 c7f10de
:truck: chore(setup): dist폴더 추적 중단
airman5573 a17868c
:memo: docs(todo): 구현할 기능 정리
jhy979 a0a4316
:recycle: refactor(typo): typo scope 추가
jhy979 e6b3bd9
:recycle: refactor(typo): prettier 적용
jhy979 d7373e9
:truck: chore(setup): 함수 15줄 제한 해제
airman5573 8f52110
:sparkles: feat(ui): component 생성
airman5573 b4a0297
:truck: chore(setup): typescript target 설정
jhy979 f1be242
:truck: chore(setup): commit scope flux 추가
jhy979 bfc5093
:sparkles: feat(flux): store 생성
jhy979 0ca6b34
:sparkles: feat(flux): flux 패턴 생성
jhy979 02c5ede
:truck: chore(setup): 명시적 any 선언을 허용한다
airman5573 6a7fc05
:sparkles: feat(decorator): custom element decorator와 event bind deco…
airman5573 c289836
:sparkles: feat(template): 상품관리탭 template, style 추가
jhy979 df84428
:truck: chore(setup): 커밋 스코프 추가
airman5573 5e7798a
:recycle: refactor(component): 컴포넌트 분리
airman5573 29c336c
:truck: chore(setup): git에서 추적하지 않을 파일 추가
airman5573 68a57ef
:sparkles: feat(ui): 상품 관리 탭에서 상품을 추가한다
airman5573 d3cda8a
:sparkles: feat(component): 상품관리탭에서 상품 수정 기능 추가
jhy979 49923c6
:sparkles: feat(component): 상품 관리 탭에서 상품 삭제
airman5573 80b19e8
:recycle: refactor(component): 반복되는 코드 함수로 분리
airman5573 b0ad8c6
:recycle: refactor(cleanup): 불필요한 코드 삭제
airman5573 ab5221a
:sparkles: feat(component): 상품 수정 삭제 기능 추가
airman5573 1b2d9d9
:recycle: refactor(ui): 상품 추가 필드 초기화 및 포커싱
airman5573 52b590b
:sparkles: feat(component): 잔돈 충전 기능 추가
jhy979 3f3ed7d
:recycle: refactor(cleanup): 사용하지 않는 type 삭제
airman5573 146aefa
:recycle: refactor(cleanup): 불필요한 eslint disable comment 삭제
airman5573 62458e4
:sparkles: feat(routing): 라우팅 기능을 추가한다
airman5573 fbb3d15
:construction_worker: build: netlify 설정 파일 추가
airman5573 870263d
:recycle: refactor(cleanup): 더미 데이터 삭제
airman5573 f0ffe42
:bug: fix(component): 동적으로 컴포넌트 그릴시 event가 재등록 되지 않는 문제 해결
airman5573 99a449e
:sparkles: feat(component): 상품 구매 탭 임시 추가 및 라우팅 구현
airman5573 7380b27
:bug: fix(component): 페이지 이동 시 nav 배경색이 변경되지 않는 에러 수정
jhy979 7d5da7e
:recycle: refactor(routing): 라우팅 시 state값을 기준으로 각 컴포넌트 내 동적 렌더링
jhy979 26718e1
:sparkles: feat(util): 객체 deep copy 유틸 함수 추가
jhy979 6c371e5
:recycle: refactor(flux): state을 얕은 복사에서 깊은 복사로 변경
jhy979 f565230
:lipstick: style(ui): 1000이상 단위 콤마 추가
jhy979 dbb6fef
:recycle: refactor(cleanup): 사용하지 않는 모듈 import 제거
jhy979 eb3d0fe
:bug: fix(routing): 라우팅 발생 전 Component 삽입
jhy979 9824bc7
:recycle: refactor(typo): config 파일에 lint 적용
jhy979 bab412b
:white_check_mark: test(validation): validation test 추가
jhy979 6b14bb0
:recycle: refactor(cleanup): 불필요한 모듈 import 제거
jhy979 d7e0fdc
:recycle: refactor: 상수 처리
jhy979 84da723
:white_check_mark: test(validation): 충전 금액 테스트 추가
jhy979 7f6920c
:recycle: refactor: 에러 메세지에 들어간 숫자를 상수로 대체
jhy979 695df52
:bug: fix(ui): 엔터 클릭으로 form 제출 방지
jhy979 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
✅ test(validation): validation test 추가
commit bab412b376b11ff93789c4ea3b29ce56807e3aa4
There are no files selected for viewing
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,83 @@ | ||
import { COIN_UNITS } from '../constants'; | ||
import Store from '../flux/store'; | ||
import { | ||
validateChargeCoins, | ||
validateProductName, | ||
validateProductPrice, | ||
validateProductQuantity, | ||
} from '../validation/validators'; | ||
|
||
const store = new Store({ | ||
activeTab: 'product-manage-tab', | ||
chargedMoney: 0, | ||
chargedCoins: COIN_UNITS, | ||
productList: [ | ||
{ | ||
name: '콜라', | ||
price: 1500, | ||
quantity: 20, | ||
isEditing: false, | ||
}, | ||
], | ||
}); | ||
|
||
describe('상품 추가 시 유효성 검사를 한다.', () => { | ||
const { productList } = store.getState(); | ||
|
||
test('상품명은 최소 1글자, 최대 10글자까지 가능하다.', () => { | ||
const productName = '사이다'; | ||
const { hasError } = validateProductName(productName, productList); | ||
console.log(productList, validateProductName(productName, productList)); | ||
expect(hasError).toBe(false); | ||
}); | ||
|
||
test('상품명이 중복되면 에러를 발생시킨다.', () => { | ||
const productName = '콜라'; | ||
const { errorMessage } = validateProductName(productName, productList); | ||
expect(errorMessage).toBe('이미 등록된 상품입니다'); | ||
}); | ||
|
||
test('상품 가격은 100원 ~ 10,000원 이내가 아니면 에러를 발생시킨다.', () => { | ||
const price = '10000000'; | ||
const { errorMessage } = validateProductPrice(price); | ||
expect(errorMessage).toBe('상품가격은 100원 ~ 10,000원 이내이어야 합니다'); | ||
}); | ||
|
||
test('상품 가격은 10원으로 나누어 떨어지지 않으면 에러를 발생시킨다.', () => { | ||
const price = '1231'; | ||
const { errorMessage } = validateProductPrice(price); | ||
expect(errorMessage).toBe('상품 가격은 10원 단위이어야 합니다'); | ||
}); | ||
|
||
test('한 제품당 수량이 1개 ~ 20개 이내가 아니며 에러를 발생시킨다.', () => { | ||
const quantity = '21'; | ||
const { errorMessage } = validateProductQuantity(quantity); | ||
expect(errorMessage).toBe('상품 수량은 1개 ~ 20개 이내이어야 합니다'); | ||
}); | ||
}); | ||
|
||
describe('잔돈 충전 시 유효성 검사를 한다.', () => { | ||
test('잔돈 입력 시 빈 값을 허용하지 않는다.', () => { | ||
const money = ''; | ||
const { errorMessage } = validateChargeCoins(money, 0); | ||
expect(errorMessage).toBe('충전 금액을 입력해주세요.'); | ||
}); | ||
|
||
test('잔돈은 숫자만 입력 가능하다.', () => { | ||
const money = 'airman55'; | ||
const { errorMessage } = validateChargeCoins(money, 0); | ||
expect(errorMessage).toBe('충전 금액은 숫자이어야 합니다'); | ||
}); | ||
|
||
test('잔돈은 10원으로 나누어 떨어지는 금액만 투입할 수 있다.', () => { | ||
const money = '1231'; | ||
const { errorMessage } = validateChargeCoins(money, 0); | ||
expect(errorMessage).toBe('충전 금액은 10원 단위이어야 합니다'); | ||
}); | ||
|
||
test('잔돈으로 보유할 수 있는 최대 금액은 100,000원이다.', () => { | ||
const money = '20000'; | ||
const { errorMessage } = validateChargeCoins(money, 90000); | ||
expect(errorMessage).toBe('잔돈으로 보유할 수 있는 최대 금액은 100,000원입니다.'); | ||
}); | ||
}); |
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.
놓쳤습니다. 제거하겠습니다 :D