Skip to content

Commit

Permalink
Merge pull request #155 from wizelineacademy/prueba-button
Browse files Browse the repository at this point in the history
chore: Added input test
  • Loading branch information
JulioEmmmanuel authored Jun 12, 2024
2 parents 0724a2d + a036e1f commit 1cdfc5b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
40 changes: 40 additions & 0 deletions src/components/ui/input.test.tsx
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')
})
})
2 changes: 1 addition & 1 deletion src/components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'

import { cn } from '@/src/lib/utils'
import { cn } from '../../lib/utils'

export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}
Expand Down

0 comments on commit 1cdfc5b

Please sign in to comment.