-
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.
Merge pull request #155 from wizelineacademy/prueba-button
chore: Added input test
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
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,40 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { describe, it, expect } from 'vitest' | ||
import { Input } from './input' | ||
|
||
describe('Input component', () => { | ||
it('renders correctly', () => { | ||
render(<Input type='text' placeholder='Enter text' />) | ||
|
||
const inputElement = screen.getByPlaceholderText('Enter text') | ||
expect(inputElement).toBeInTheDocument() | ||
}) | ||
|
||
it('applies custom class correctly', () => { | ||
render(<Input type='text' className='custom-class' />) | ||
|
||
const inputElement = screen.getByRole('textbox') | ||
expect(inputElement).toHaveClass('custom-class') | ||
}) | ||
|
||
it('is disabled when disabled prop is true', () => { | ||
render(<Input type='text' disabled />) | ||
|
||
const inputElement = screen.getByRole('textbox') | ||
expect(inputElement).toBeDisabled() | ||
}) | ||
|
||
it('displays the correct placeholder text', () => { | ||
render(<Input type='text' placeholder='Enter text' />) | ||
|
||
const inputElement = screen.getByPlaceholderText('Enter text') | ||
expect(inputElement).toHaveAttribute('placeholder', 'Enter text') | ||
}) | ||
|
||
it('sets the correct input type', () => { | ||
render(<Input type='text' />) | ||
|
||
const inputElement = screen.getByRole('textbox') | ||
expect(inputElement).toHaveAttribute('type', 'text') | ||
}) | ||
}) |
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