-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(button): button test 파일 생성 및 test.yml파일 테스트
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { Button } from './button'; | ||
|
||
describe('Button', () => { | ||
it('renders correctly', () => { | ||
render(<Button>Click me</Button>); | ||
expect(screen.getByText('Click me')).toBeInTheDocument(); | ||
}); | ||
|
||
it('handles click events', async () => { | ||
const handleClick = jest.fn(); | ||
render(<Button onClick={handleClick}>Click me</Button>); | ||
await userEvent.click(screen.getByText('Click me')); | ||
expect(handleClick).toHaveBeenCalled(); | ||
}); | ||
|
||
it('renders with variant classes', () => { | ||
render(<Button variant="destructive">Delete</Button>); | ||
expect(screen.getByText('Delete')).toHaveClass('bg-destructive'); | ||
}); | ||
}); |