Fix new test-library eslint errors

This commit is contained in:
Deluan
2022-09-28 21:30:20 -04:00
parent 86ab35069d
commit 6b09dc7198
7 changed files with 100 additions and 92 deletions
+6 -8
View File
@@ -1,5 +1,5 @@
import * as React from 'react'
import { render, cleanup } from '@testing-library/react'
import { render, cleanup, screen } from '@testing-library/react'
import { MultiLineTextField } from './MultiLineTextField'
describe('<MultiLineTextField />', () => {
@@ -7,24 +7,22 @@ describe('<MultiLineTextField />', () => {
it('should render each line in a separated div', () => {
const record = { comment: 'line1\nline2' }
const { queryByTestId } = render(
<MultiLineTextField record={record} source={'comment'} />
)
expect(queryByTestId('comment.0').textContent).toBe('line1')
expect(queryByTestId('comment.1').textContent).toBe('line2')
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) => {
const { queryByText } = render(
render(
<MultiLineTextField
record={{ id: 123, body }}
emptyText="NA"
source="body"
/>
)
expect(queryByText('NA')).not.toBeNull()
expect(screen.getByText('NA')).toBeInTheDocument()
}
)
})