-
Notifications
You must be signed in to change notification settings - Fork 0
chore: Vitest 유닛 테스트 환경 초기 설정 #562
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
Open
kanghaeun
wants to merge
2
commits into
dev
Choose a base branch
from
chore/561-vitest-setup
base: dev
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
2 commits
Select commit
Hold shift + click to select a range
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 contains hidden or 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 hidden or 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 hidden or 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
43 changes: 43 additions & 0 deletions
43
apps/web/src/app/tournament/[id]/create/_utils/tournamentItemBasket.test.ts
This file contains hidden or 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,43 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { BASKET_COUNT, ITEMS_PER_BASKET } from '../_consts/tournamentItemBasket'; | ||
| import { getActiveBasketCount, getBasketIndexForLastItem } from './tournamentItemBasket'; | ||
|
|
||
| const MAX_ITEM_COUNT = ITEMS_PER_BASKET * BASKET_COUNT; | ||
|
|
||
| describe('getActiveBasketCount', () => { | ||
| it('아이템이 없으면 빈 바구니 1개를 보여준다', () => { | ||
| expect(getActiveBasketCount(0)).toBe(1); | ||
| }); | ||
|
|
||
| it('바구니가 채워지는 중이면 채워진 바구니까지만 보여준다', () => { | ||
| expect(getActiveBasketCount(1)).toBe(1); | ||
| expect(getActiveBasketCount(ITEMS_PER_BASKET - 1)).toBe(1); | ||
| expect(getActiveBasketCount(ITEMS_PER_BASKET + 1)).toBe(2); | ||
| }); | ||
|
|
||
| it('바구니가 꽉 차면 다음 빈 바구니를 미리 열어준다', () => { | ||
| expect(getActiveBasketCount(ITEMS_PER_BASKET)).toBe(2); | ||
| expect(getActiveBasketCount(ITEMS_PER_BASKET * 2)).toBe(3); | ||
| }); | ||
|
|
||
| it('마지막 바구니가 꽉 차도 BASKET_COUNT 를 넘기지 않는다', () => { | ||
| expect(getActiveBasketCount(MAX_ITEM_COUNT - 1)).toBe(BASKET_COUNT); | ||
| expect(getActiveBasketCount(MAX_ITEM_COUNT)).toBe(BASKET_COUNT); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getBasketIndexForLastItem', () => { | ||
| it('아이템이 없으면 첫 번째 바구니를 가리킨다', () => { | ||
| expect(getBasketIndexForLastItem(0)).toBe(0); | ||
| }); | ||
|
|
||
| it('바구니 경계에서 다음 바구니로 넘어간다', () => { | ||
| expect(getBasketIndexForLastItem(ITEMS_PER_BASKET)).toBe(0); | ||
| expect(getBasketIndexForLastItem(ITEMS_PER_BASKET + 1)).toBe(1); | ||
| }); | ||
|
|
||
| it('마지막 바구니 인덱스를 넘기지 않는다', () => { | ||
| expect(getBasketIndexForLastItem(MAX_ITEM_COUNT)).toBe(BASKET_COUNT - 1); | ||
| }); | ||
| }); | ||
This file contains hidden or 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,15 @@ | ||
| import path from 'node:path'; | ||
| import { defineConfig } from 'vitest/config'; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| environment: 'node', | ||
| include: ['src/**/*.test.ts'], | ||
| exclude: ['node_modules/**', '.next/**', 'e2e/**'], | ||
| }, | ||
| resolve: { | ||
| alias: { | ||
| '@': path.resolve(import.meta.dirname, './src'), | ||
| }, | ||
| }, | ||
| }); |
This file contains hidden or 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.
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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
샘플 테스트 수를 연결 이슈 요구사항에 맞추세요.
getActiveBasketCount에 네 개의it블록을 추가했습니다. 연결된#561요구사항은 이 함수의 샘플 테스트를 최대 한 개로 제한합니다. 요구사항이 아직 유효하면 경계값 검증을 한 블록으로 합치고 나머지 테스트는 후속 작업으로 이동하세요.🤖 Prompt for AI Agents