Skip to content

Commit

Permalink
fix(#3319): add regression test for component children
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Moore committed May 19, 2022
1 parent 5dd8ee4 commit 18bd57d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/astro/test/astro-markdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ describe('Astro Markdown', () => {
expect($('h1').attr("id")).to.equal('my-blog-post');
});

it('Correctly handles component children in markdown pages (#3319)', async () => {
const html = await fixture.readFile('/children/index.html');

console.log(html);
expect(html).not.to.contain('<p></p>');
});

it('Can load more complex jsxy stuff', async () => {
const html = await fixture.readFile('/complex/index.html');
const $ = cheerio.load(html);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { h } from 'preact';

const TextBlock = ({
title,
children,
noPadding = false,
}) => {
return (
<div
className={`${
noPadding ? "" : "md:px-2 lg:px-4"
} flex-1 prose prose-headings:font-grotesk`}
>
<h3>{title}</h3>
<p>{children}</p>
</div>
);
};

export default TextBlock;
12 changes: 12 additions & 0 deletions packages/astro/test/fixtures/astro-markdown/src/pages/children.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
setup: import TextBlock from '../components/TextBlock'
---
{/* https://github.com/withastro/astro/issues/3319 */}

<TextBlock title="Hello world!" noPadding>
<ul class="not-prose">
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
</TextBlock>

0 comments on commit 18bd57d

Please sign in to comment.