-
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.
Merge branch 'main' into refact/textarea
- Loading branch information
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'); | ||
}); | ||
}); |