-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(Tab): 유닛 테스트 코드 작성 * feat(Tab): 스토리북으로 translator 동작 확인을 위한 args 추가
- Loading branch information
1 parent
325667f
commit 764be23
Showing
2 changed files
with
34 additions
and
5 deletions.
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
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,28 @@ | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import Tab from '../Tab'; | ||
|
||
describe('Tab 컴포넌트는', () => { | ||
const mockOnChange = vi.fn(); | ||
const tabItems = ['Tab1', 'Tab2', 'Tab3']; | ||
|
||
function renderTab() { | ||
render(<Tab onChange={mockOnChange} size='md' style='primary' tabItems={tabItems} />); | ||
} | ||
|
||
it('정상적으로 렌더링이 됩니다.', () => { | ||
renderTab(); | ||
|
||
tabItems.forEach((item) => { | ||
expect(screen.getByText(item)).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('탭을 클릭하면 onChange 핸들러가 호출됩니다.', () => { | ||
renderTab(); | ||
|
||
fireEvent.click(screen.getByText('Tab2')); | ||
|
||
expect(mockOnChange).toHaveBeenCalledWith('Tab2'); | ||
}); | ||
}); |