Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-core/src/components/List/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const ListItem: React.FunctionComponent<ListItemProps> = ({
}: ListItemProps) => (
<li className={css(icon && styles.listItem, className)} {...props}>
{icon && <span className={css(styles.listItemIcon)}>{icon}</span>}
<span className={icon && css(`${styles.list}__item-text`)}>{children}</span>
{icon ? <span className={css(`${styles.list}__item-text`)}>{children}</span> : children}
</li>
);
ListItem.displayName = 'ListItem';
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render, screen } from '@testing-library/react';
import { ListItem } from '../ListItem';
import { Content } from '../../Content';
import styles from '@patternfly/react-styles/css/components/List/list';

test('Renders with children', () => {
Expand All @@ -8,6 +9,16 @@ test('Renders with children', () => {
expect(screen.getByRole('listitem')).toHaveTextContent('List item content');
});

test('Renders block content without an inline wrapper when there is no icon', () => {
render(
<ListItem>
<Content data-testid="content">List item content</Content>
</ListItem>
);

expect(screen.getByTestId('content').parentElement).toBe(screen.getByRole('listitem'));
});

test(`Does not render with a class by default`, () => {
render(<ListItem>List item content</ListItem>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ exports[`Matches snapshot with icon 1`] = `
exports[`Matches snapshot without icon 1`] = `
<DocumentFragment>
<li>
<span>
List item content
</span>
List item content
</li>
</DocumentFragment>
`;