import React from 'react'
import { render, snapshot } from '../utils/test-utils'
import { NaturalLanguageInput } from './input'
import userEvent from '@testing-library/user-event'
describe('NaturalLanguageInput', () => {
describe('snapshots', () => {
snapshot(
'with a placeholder',
)
snapshot(
'with a defaultValue',
)
snapshot('with a value', )
snapshot(
'when read only',
)
})
describe('interaction', () => {
it('should work uncontrolled', async () => {
const onChange = jest.fn()
const { getByRole } = render(
)
await userEvent.keyboard('{Tab}20')
expect(getByRole('textbox', { name: 'Age' })).toHaveValue('20')
expect(onChange).toHaveBeenCalledWith('20')
})
it('should work controlled', async () => {
const onChange = jest.fn()
const { getByRole } = render(
)
await userEvent.keyboard('{Tab}20')
expect(getByRole('textbox', { name: 'Age' })).toHaveValue('10')
expect(onChange).toHaveBeenCalledWith('2')
})
})
})