test: improve coverage for some files (#33218)

This commit is contained in:
Saumya Talwani
2026-03-12 12:39:10 +05:30
committed by GitHub
parent 68982f910e
commit ed5511ce28
61 changed files with 3191 additions and 304 deletions

View File

@ -151,6 +151,43 @@ describe('BlockInput', () => {
expect(screen.queryByRole('textbox')).not.toBeInTheDocument()
})
it('should handle change when onConfirm is not provided', async () => {
render(<BlockInput value="Hello" />)
const contentArea = screen.getByText('Hello')
fireEvent.click(contentArea)
const textarea = await screen.findByRole('textbox')
fireEvent.change(textarea, { target: { value: 'Hello World' } })
expect(textarea).toHaveValue('Hello World')
})
it('should enter edit mode when clicked with empty value', async () => {
render(<BlockInput value="" />)
const contentArea = screen.getByTestId('block-input').firstChild as Element
fireEvent.click(contentArea)
const textarea = await screen.findByRole('textbox')
expect(textarea).toBeInTheDocument()
})
it('should exit edit mode on blur', async () => {
render(<BlockInput value="Hello" />)
const contentArea = screen.getByText('Hello')
fireEvent.click(contentArea)
const textarea = await screen.findByRole('textbox')
expect(textarea).toBeInTheDocument()
fireEvent.blur(textarea)
await waitFor(() => {
expect(screen.queryByRole('textbox')).not.toBeInTheDocument()
})
})
})
describe('Edge Cases', () => {
@ -168,8 +205,9 @@ describe('BlockInput', () => {
})
it('should handle newlines in value', () => {
render(<BlockInput value="line1\nline2" />)
const { container } = render(<BlockInput value={`line1\nline2`} />)
expect(screen.getByText(/line1/)).toBeInTheDocument()
expect(container.querySelector('br')).toBeInTheDocument()
})
it('should handle multiple same variables', () => {