feat: etf 추천 로직 테스트코드 작성 #197
Merged
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.
📌 연관된 이슈 번호
🌱 주요 변경 사항
1. ETF 추천 서비스 테스트 구현 (
__tests__/services/etf-recommend-service.test.ts)EtfRecommendService 클래스 전체 테스트 커버리지
getRecommendations()메서드 테스트getEtfData()메서드 테스트processEtfData()메서드 테스트calculateMetrics()메서드 테스트calculateEtfScores()메서드 테스트에러 케이스 테스트
InvestmentProfileNotFoundError)NoEtfDataError)NoTradingDataError)투자 성향별 필터링 테스트
2. API 엔드포인트 테스트 (
__tests__/api/etf-recommend-api.test.ts)인증 테스트
서비스 로직 테스트
에러 처리 테스트
3. 유틸리티 함수 테스트
위험등급 분류 함수 (
classifyRiskGrade)샤프비율 계산 함수 (
calculateSharpeRatio)투자 성향별 가중치 함수 (
getRiskBasedWeights)허용 위험등급 함수 (
getAllowedRiskGrades)정규화 함수들 (
normalize,normalizeVolatilityByRiskGrade)추천 이유 생성 함수 (
generateReasons)4. 테스트 헬퍼 함수 구현 (
__tests__/helpers/etf-recommend-helpers.ts)Mock 데이터 생성 함수들
createMockEtfData(): ETF 데이터 모킹createMockProcessedEtfData(): 처리된 ETF 데이터 모킹createMockMetricsData(): 메트릭 데이터 모킹createMockWeightsData(): 가중치 데이터 모킹createMockEtfRecommendationResponse(): 추천 응답 모킹투자 성향별 테스트 데이터
createConservativeEtfData(): 보수형 ETF 데이터createAggressiveEtfData(): 공격형 ETF 데이터getTestRiskGradesByInvestType(): 투자 성향별 허용 위험등급🎯 주요 개선사항
1. 테스트 커버리지 확대
2. 테스트 가독성 향상
테스트 결과
📸 스크린샷 (선택)