Skip to content

Commit

Permalink
Add test for direct usage of nested component
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Feb 6, 2023
1 parent 963ff33 commit e27b5c5
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/integrations/mdx/test/css-head-mdx.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,17 @@ describe('Head injection w/ MDX', () => {
const links = document.querySelectorAll('head link[rel=stylesheet]');
expect(links).to.have.a.lengthOf(1);
});

it.skip('injects content from a component using Content#render()', async () => {
const html = await fixture.readFile('/DirectContentUsage/index.html');
console.log(html);
const { document } = parseHTML(html);

const links = document.querySelectorAll('head link[rel=stylesheet]');
expect(links).to.have.a.lengthOf(1);

const scripts = document.querySelectorAll('head script[type=module]');
expect(scripts).to.have.a.lengthOf(1);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
import { getEntryBySlug } from 'astro:content';
const launchWeek = await getEntryBySlug('blog', 'using-mdx');
const { Content } = await launchWeek.render();
debugger;
---

<Content />
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
---

<script>
console.log('hoisted')
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {
color: red !important;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import './_styles.css';
import WithHoistedScripts from '../../components/WithHoistedScripts.astro';

# Using mdx

<WithHoistedScripts />
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
import UsingMdx from '../components/UsingMdx.astro'
---

<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Astro</title>
</head>
<body>
<h1>Astro</h1>
<UsingMdx />
</body>
</html>

0 comments on commit e27b5c5

Please sign in to comment.