Skip to content
Merged
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
12 changes: 6 additions & 6 deletions __tests__/api/challenge-claim-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('/api/challenge/claim', () => {
});

describe('POST', () => {
it('should return 401 when not authenticated', async () => {
it('인증되지 않은 경우 401을 반환한다', async () => {
mockGetServerSession.mockResolvedValue(null);

const request = new Request('http://localhost/api/challenge/claim', {
Expand All @@ -54,7 +54,7 @@ describe('/api/challenge/claim', () => {
expect(data.message).toBe('Unauthorized');
});

it('should return 400 when challengeId is missing', async () => {
it('challengeId가 없는 경우 400을 반환한다', async () => {
mockGetServerSession.mockResolvedValue({
user: { id: '1' },
});
Expand All @@ -71,7 +71,7 @@ describe('/api/challenge/claim', () => {
expect(data.message).toBe('Challenge ID is required');
});

it('should successfully claim challenge reward', async () => {
it('챌린지 보상을 정상적으로 수령하면 200을 반환한다', async () => {
mockGetServerSession.mockResolvedValue({
user: { id: '1' },
});
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('/api/challenge/claim', () => {
);
});

it('should return 500 when cannot claim challenge', async () => {
it('보상을 받을 수 없는 챌린지인 경우 500을 반환한다', async () => {
mockGetServerSession.mockResolvedValue({
user: { id: '1' },
});
Expand All @@ -138,7 +138,7 @@ describe('/api/challenge/claim', () => {
expect(data.message).toBe('Already claimed');
});

it('should return 400 when claim service returns failure', async () => {
it('보상 처리 중 실패한 경우 400을 반환한다', async () => {
mockGetServerSession.mockResolvedValue({
user: { id: '1' },
});
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('/api/challenge/claim', () => {
expect(data.message).toBe('ISA account not found');
});

it('should handle unexpected errors', async () => {
it('예상치 못한 오류가 발생하면 500을 반환한다', async () => {
mockGetServerSession.mockResolvedValue({
user: { id: '1' },
});
Expand Down
14 changes: 7 additions & 7 deletions __tests__/services/challenge-claim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Challenge Claim Service', () => {
mockTx = createChallengePrismaMock();
});

it('should successfully claim ONCE type challenge reward', async () => {
it('ONCE 타입 챌린지 보상을 정상적으로 수령한다', async () => {
// Arrange
const mockChallenge = {
id: challengeId,
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('Challenge Claim Service', () => {
expect(mockTx.userChallengeProgress.updateMany).not.toHaveBeenCalled();
});

it('should successfully claim DAILY type challenge reward and reset progress', async () => {
it('DAILY 타입 챌린지 보상을 정상적으로 수령하고 진행도를 초기화한다', async () => {
// Arrange
const mockChallenge = {
id: challengeId,
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('Challenge Claim Service', () => {
});
});

it('should return error when challenge not found', async () => {
it('챌린지를 찾을 수 없으면 에러를 반환한다', async () => {
mockTx.challenge.findUnique.mockResolvedValue(null);

const result = await claimChallengeReward({ challengeId, userId }, mockTx);
Expand All @@ -149,7 +149,7 @@ describe('Challenge Claim Service', () => {
expect(result.message).toBe('Challenge not found');
});

it('should return error when ISA account not found', async () => {
it('ISA 계좌를 찾을 수 없으면 에러를 반환한다', async () => {
const mockChallenge = {
id: challengeId,
etfId,
Expand All @@ -172,7 +172,7 @@ describe('Challenge Claim Service', () => {
expect(result.message).toBe('ISA account not found');
});

it('should return error when latest ETF price not found', async () => {
it('최신 ETF 가격을 찾을 수 없으면 에러를 반환한다', async () => {
const mockChallenge = {
id: challengeId,
etfId,
Expand All @@ -196,7 +196,7 @@ describe('Challenge Claim Service', () => {
expect(result.message).toBe('Latest ETF price not found');
});

it('should handle existing ETF holding correctly', async () => {
it('기존 ETF 보유 내역이 있는 경우 올바르게 처리한다', async () => {
// Arrange
const mockChallenge = {
id: challengeId,
Expand Down Expand Up @@ -276,7 +276,7 @@ describe('Challenge Claim Service', () => {
});
});

it('should correctly calculate avgCost when quantity and price have decimals', async () => {
it('수량과 가격이 소수일 경우 평균 단가를 올바르게 계산한다', async () => {
const mockChallenge = {
id: challengeId,
etfId,
Expand Down
28 changes: 14 additions & 14 deletions __tests__/services/challenge-status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Challenge Status Service', () => {
const today = dayjs().tz('Asia/Seoul').startOf('day');

describe('calculateChallengeStatus', () => {
it('should return CLAIMED when challenge is already claimed', () => {
it('이미 보상을 수령한 챌린지는 CLAIMED를 반환한다', () => {
const challenge: ChallengeWithProgress = {
id: BigInt(1),
challengeType: 'ONCE',
Expand All @@ -30,7 +30,7 @@ describe('Challenge Status Service', () => {
expect(status).toBe('CLAIMED');
});

it('should return ACHIEVABLE for ONCE type when progress >= 1', () => {
it('ONCE 타입 챌린지는 진행도가 1 이상이면 ACHIEVABLE을 반환한다', () => {
const challenge: ChallengeWithProgress = {
id: BigInt(1),
challengeType: 'ONCE',
Expand All @@ -44,7 +44,7 @@ describe('Challenge Status Service', () => {
expect(status).toBe('ACHIEVABLE');
});

it('should return INCOMPLETE for ONCE type when progress < 1', () => {
it('ONCE 타입 챌린지는 진행도가 1 미만이면 INCOMPLETE를 반환한다', () => {
const challenge: ChallengeWithProgress = {
id: BigInt(1),
challengeType: 'ONCE',
Expand All @@ -58,7 +58,7 @@ describe('Challenge Status Service', () => {
expect(status).toBe('INCOMPLETE');
});

it('should return ACHIEVABLE for STREAK type when progress >= 7 and updated today', () => {
it('STREAK 타입 챌린지는 진행도 7 이상이고 오늘 갱신됐으면 ACHIEVABLE을 반환한다', () => {
const challenge: ChallengeWithProgress = {
id: BigInt(1),
challengeType: 'STREAK',
Expand All @@ -76,7 +76,7 @@ describe('Challenge Status Service', () => {
expect(status).toBe('ACHIEVABLE');
});

it('should return INCOMPLETE for STREAK type when progress >= 7 but not updated today', () => {
it('STREAK 타입 챌린지는 진행도 7 이상이어도 오늘 갱신되지 않았으면 INCOMPLETE를 반환한다', () => {
const yesterday = today.subtract(1, 'day');
const challenge: ChallengeWithProgress = {
id: BigInt(1),
Expand All @@ -95,7 +95,7 @@ describe('Challenge Status Service', () => {
expect(status).toBe('INCOMPLETE');
});

it('should return ACHIEVABLE for DAILY type when progress > 0 and updated today', () => {
it('DAILY 타입 챌린지는 진행도가 0보다 크고 오늘 갱신됐으면 ACHIEVABLE을 반환한다', () => {
const challenge: ChallengeWithProgress = {
id: BigInt(1),
challengeType: 'DAILY',
Expand All @@ -113,7 +113,7 @@ describe('Challenge Status Service', () => {
expect(status).toBe('ACHIEVABLE');
});

it('should return ACHIEVABLE for DAILY type when progress > 0 and created today', () => {
it('DAILY 타입 챌린지는 진행도가 0보다 크고 오늘 생성됐으면 ACHIEVABLE을 반환한다', () => {
const challenge: ChallengeWithProgress = {
id: BigInt(1),
challengeType: 'DAILY',
Expand All @@ -131,7 +131,7 @@ describe('Challenge Status Service', () => {
expect(status).toBe('ACHIEVABLE');
});

it('should return CLAIMED for DAILY type when already claimed today', () => {
it('DAILY 타입 챌린지는 오늘 이미 보상을 수령했으면 CLAIMED를 반환한다', () => {
const challenge: ChallengeWithProgress = {
id: BigInt(1),
challengeType: 'DAILY',
Expand All @@ -149,7 +149,7 @@ describe('Challenge Status Service', () => {
expect(status).toBe('CLAIMED');
});

it('should return INCOMPLETE for DAILY type when progress = 0 even if updated today', () => {
it('DAILY 타입 챌린지는 진행도가 0이면 오늘 갱신됐더라도 INCOMPLETE를 반환한다', () => {
const challenge: ChallengeWithProgress = {
id: BigInt(1),
challengeType: 'DAILY',
Expand All @@ -167,7 +167,7 @@ describe('Challenge Status Service', () => {
expect(status).toBe('INCOMPLETE');
});

it('should return INCOMPLETE if no progress data exists', () => {
it('진행도 정보가 없으면 INCOMPLETE를 반환한다', () => {
const challenge: ChallengeWithProgress = {
id: BigInt(1),
challengeType: 'ONCE',
Expand All @@ -187,7 +187,7 @@ describe('Challenge Status Service', () => {
mockTx = createChallengePrismaMock();
});

it('should return false when challenge not found', async () => {
it('챌린지를 찾을 수 없으면 false를 반환하고 이유를 제공한다', async () => {
mockTx.challenge.findUnique.mockResolvedValue(null);

const result = await canClaimChallenge(BigInt(1), userId, mockTx);
Expand All @@ -196,7 +196,7 @@ describe('Challenge Status Service', () => {
expect(result.reason).toBe('Challenge not found');
});

it('should return false when already claimed', async () => {
it('이미 보상을 수령한 챌린지는 false를 반환하고 이유를 제공한다', async () => {
const mockChallenge = {
id: BigInt(1),
challengeType: 'ONCE',
Expand All @@ -214,7 +214,7 @@ describe('Challenge Status Service', () => {
expect(result.reason).toBe('Already claimed');
});

it('should return true when challenge is achievable', async () => {
it('보상이 가능한 챌린지는 true를 반환한다', async () => {
const mockChallenge = {
id: BigInt(1),
challengeType: 'ONCE',
Expand All @@ -232,7 +232,7 @@ describe('Challenge Status Service', () => {
expect(result.reason).toBeUndefined();
});

it('should return false when challenge is not completed', async () => {
it('완료되지 않은 챌린지는 false를 반환하고 이유를 제공한다', async () => {
const mockChallenge = {
id: BigInt(1),
challengeType: 'ONCE',
Expand Down
8 changes: 1 addition & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,5 @@
".next/types/**/*.ts",
"types/next-auth.d.ts"
],
"exclude": [
"node_modules",
"**/__tests__/**",
"**/__mocks__/**",
"**/*.test.ts",
"**/*.test.tsx"
]
"exclude": ["node_modules"]
}