mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-03-01 12:44:17 +00:00
33 lines
857 B
TypeScript
33 lines
857 B
TypeScript
import { render, screen, fireEvent } from '@testing-library/react'
|
|
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
|
|
|
import ComboBoxInput from './ComboBoxInput'
|
|
|
|
describe('<ComboBoxInput />', () => {
|
|
let wrapper: ReturnType<typeof render>
|
|
|
|
const updateFormValue = vi.fn()
|
|
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
wrapper = render(
|
|
<ComboBoxInput
|
|
value={'option-1'}
|
|
onValueChange={updateFormValue}
|
|
options={['Option 1', 'Option 2']}
|
|
/>,
|
|
)
|
|
})
|
|
|
|
it('renders properly', () => {
|
|
expect(wrapper.container.firstChild).toMatchSnapshot()
|
|
})
|
|
|
|
describe('handleChange', () => {
|
|
it('calls updateFormValue with new value', () => {
|
|
fireEvent.change(screen.getByRole('combobox'), { target: { value: 'Option 2' } })
|
|
expect(updateFormValue).toBeCalledWith('Option 2')
|
|
})
|
|
})
|
|
})
|