| 1 |
import { render, screen } from '@testing-library/react'; |
| 2 |
import { ExpandableRowContent } from '../ExpandableRowContent'; |
| 3 |
import styles from '@patternfly/react-styles/css/components/Table/table'; |
| 4 |
|
| 5 |
test('Renders without children', () => { |
| 6 |
render(<ExpandableRowContent data-testid="row-id" />); |
| 7 |
|
| 8 |
expect(screen.getByTestId('row-id')).toBeInTheDocument(); |
| 9 |
}); |
| 10 |
|
| 11 |
test('Renders with children', () => { |
| 12 |
render(<ExpandableRowContent>Row content</ExpandableRowContent>); |
| 13 |
|
| 14 |
expect(screen.getByText('Row content')).toBeVisible(); |
| 15 |
}); |
| 16 |
|
| 17 |
test(`Renders only with class ${styles.tableExpandableRowContent} by default`, () => { |
| 18 |
render(<ExpandableRowContent>Row content</ExpandableRowContent>); |
| 19 |
|
| 20 |
expect(screen.getByText('Row content')).toHaveClass(styles.tableExpandableRowContent, { exact: true }); |
| 21 |
}); |
| 22 |
|
| 23 |
test(`Renders with class ${styles.modifiers.noBackground} when hasNoBackground is true`, () => { |
| 24 |
render(<ExpandableRowContent hasNoBackground>Row content</ExpandableRowContent>); |
| 25 |
|
| 26 |
expect(screen.getByText('Row content')).toHaveClass(styles.modifiers.noBackground); |
| 27 |
}); |
| 28 |
|
| 29 |
test(`Spreads additional props`, () => { |
| 30 |
render(<ExpandableRowContent data-custom="true">Row content</ExpandableRowContent>); |
| 31 |
|
| 32 |
expect(screen.getByText('Row content')).toHaveAttribute('data-custom', 'true'); |
| 33 |
}); |
| 34 |
|
| 35 |
test('Matches snapshot', () => { |
| 36 |
const { asFragment } = render(<ExpandableRowContent>Row content</ExpandableRowContent>); |
| 37 |
|
| 38 |
expect(asFragment()).toMatchSnapshot(); |
| 39 |
}); |