quintodrome/ui/src/common/MultiLineTextField.test.jsx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
863 B
React
Raw Normal View History

import * as React from 'react'
2022-09-28 17:30:20 -08:00
import { render, cleanup, screen } from '@testing-library/react'
2020-11-13 20:25:25 -09:00
import { MultiLineTextField } from './MultiLineTextField'
describe('<MultiLineTextField />', () => {
afterEach(cleanup)
it('should render each line in a separated div', () => {
const record = { comment: 'line1\nline2' }
2022-09-28 17:30:20 -08:00
render(<MultiLineTextField record={record} source={'comment'} />)
expect(screen.queryByTestId('comment.0').textContent).toBe('line1')
expect(screen.queryByTestId('comment.1').textContent).toBe('line2')
})
it.each([null, undefined])(
'should render the emptyText when value is %s',
(body) => {
2022-09-28 17:30:20 -08:00
render(
<MultiLineTextField
record={{ id: 123, body }}
emptyText="NA"
source="body"
/>,
)
2022-09-28 17:30:20 -08:00
expect(screen.getByText('NA')).toBeInTheDocument()
},
)
})