Skip to content
This repository has been archived by the owner on Mar 23, 2022. It is now read-only.

Commit

Permalink
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/elements/markdown/main.test.tsx
Original file line number Diff line number Diff line change
@@ -46,6 +46,16 @@ describe('Markdown', () => {
expect(screen.getByText('Y', {selector: 'td'})).toBeInTheDocument();
});

it('does not crash if the table is incomplete', async () => {
const tableText = 'head | col 2\n:---: | :---:\nX';

renderReact(() => <Markdown>{tableText}</Markdown>);

expect(screen.getByText('head', {selector: 'th'})).toBeInTheDocument();
expect(screen.getByText('col 2', {selector: 'th'})).toBeInTheDocument();
expect(screen.getByText('X', {selector: 'td'})).toBeInTheDocument();
});

it('renders multiple tables correctly', async () => {
const tableText = 'head | col 2\n:---: | :---:\nX | Y';
const table2Text = 'footer | col B\n:---: | :---:\nZ | A';
4 changes: 4 additions & 0 deletions src/components/elements/markdown/transformers/text/main.tsx
Original file line number Diff line number Diff line change
@@ -44,6 +44,10 @@ type TextChildrenProps = {
}

export const TextChildren = ({children}: TextChildrenProps) => {
if (!children) {
return <></>;
}

return (
<>
{

0 comments on commit 9bfd85a

Please sign in to comment.