diff options
Diffstat (limited to 'packages/integrations')
12 files changed, 160 insertions, 0 deletions
diff --git a/packages/integrations/mdx/test/css-head-mdx.test.js b/packages/integrations/mdx/test/css-head-mdx.test.js new file mode 100644 index 000000000..a6492c3ba --- /dev/null +++ b/packages/integrations/mdx/test/css-head-mdx.test.js @@ -0,0 +1,33 @@ +import mdx from '@astrojs/mdx'; + +import { expect } from 'chai'; +import { parseHTML } from 'linkedom'; +import { loadFixture } from '../../../astro/test/test-utils.js'; + +describe('Head injection w/ MDX', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: new URL('./fixtures/css-head-mdx/', import.meta.url), + integrations: [mdx()], + }); + }); + + describe('build', () => { + before(async () => { + await fixture.build(); + }); + + it('only injects contents into head', async () => { + const html = await fixture.readFile('/indexThree/index.html'); + const { document } = parseHTML(html); + + const links = document.querySelectorAll('link[rel=stylesheet]'); + expect(links).to.have.a.lengthOf(1); + + const scripts = document.querySelectorAll('script[type=module]'); + expect(scripts).to.have.a.lengthOf(1); + }); + }); +}); diff --git a/packages/integrations/mdx/test/fixtures/css-head-mdx/src/components/HelloWorld.astro b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/components/HelloWorld.astro new file mode 100644 index 000000000..ee8084b46 --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/components/HelloWorld.astro @@ -0,0 +1,11 @@ +---
+---
+
+<h3>Hello world!!</h3>
+<slot />
+
+<style>h3 { color: red }</style>
+
+<script>
+console.log('hellooooo')
+</script>
\ No newline at end of file diff --git a/packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/One.astro b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/One.astro new file mode 100644 index 000000000..b9916e106 --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/One.astro @@ -0,0 +1,15 @@ +---
+---
+
+<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>
+ <slot />
+ </body>
+</html>
\ No newline at end of file diff --git a/packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/Three.astro b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/Three.astro new file mode 100644 index 000000000..3f0fdfa72 --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/Three.astro @@ -0,0 +1,6 @@ +---
+import Two from './Two.astro'
+---
+<Two>
+<slot />
+</Two>
\ No newline at end of file diff --git a/packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/Two.astro b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/Two.astro new file mode 100644 index 000000000..51f0ca18c --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/Two.astro @@ -0,0 +1,6 @@ +---
+import One from './One.astro'
+---
+<One>
+<slot />
+</One>
\ No newline at end of file diff --git a/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexOne.astro b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexOne.astro new file mode 100644 index 000000000..f24bf4f3c --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexOne.astro @@ -0,0 +1,10 @@ +--- +import One from '../layouts/One.astro' + +import { Content } from '../test.mdx' +--- + +<One> + <h1>Astro</h1> + <Content /> +</One> diff --git a/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexThree.astro b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexThree.astro new file mode 100644 index 000000000..99be9677c --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexThree.astro @@ -0,0 +1,10 @@ +---
+import Three from '../layouts/Three.astro'
+
+import { Content } from '../test.mdx'
+---
+
+<Three>
+ <h1>Astro</h1>
+ <Content />
+</Three>
diff --git a/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexTwo.astro b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexTwo.astro new file mode 100644 index 000000000..af07af926 --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexTwo.astro @@ -0,0 +1,10 @@ +---
+import Two from '../layouts/Two.astro'
+
+import { Content } from '../test.mdx'
+---
+
+<Two>
+ <h1>Astro</h1>
+ <Content />
+</Two>
diff --git a/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testOne.mdx b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testOne.mdx new file mode 100644 index 000000000..6874b499f --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testOne.mdx @@ -0,0 +1,15 @@ +---
+layout: '../layouts/One.astro'
+title: "hello world"
+publishDate: "2023-01-01"
+---
+
+import HelloWorld from '../components/HelloWorld.astro';
+
+# Test
+
+123
+
+<HelloWorld />
+
+456
diff --git a/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testThree.mdx b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testThree.mdx new file mode 100644 index 000000000..b0e55eed2 --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testThree.mdx @@ -0,0 +1,15 @@ +---
+layout: '../layouts/Three.astro'
+title: "hello world"
+publishDate: "2023-01-01"
+---
+
+import HelloWorld from '../components/HelloWorld.astro';
+
+# Test
+
+123
+
+<HelloWorld />
+
+456
diff --git a/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testTwo.mdx b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testTwo.mdx new file mode 100644 index 000000000..9a80ed5f0 --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testTwo.mdx @@ -0,0 +1,15 @@ +---
+layout: '../layouts/Two.astro'
+title: "hello world"
+publishDate: "2023-01-01"
+---
+
+import HelloWorld from '../components/HelloWorld.astro';
+
+# Test
+
+123
+
+<HelloWorld />
+
+456
diff --git a/packages/integrations/mdx/test/fixtures/css-head-mdx/src/test.mdx b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/test.mdx new file mode 100644 index 000000000..c8ecc4daa --- /dev/null +++ b/packages/integrations/mdx/test/fixtures/css-head-mdx/src/test.mdx @@ -0,0 +1,14 @@ +---
+title: "hello world"
+publishDate: "2023-01-01"
+---
+
+import HelloWorld from './components/HelloWorld.astro';
+
+# Test
+
+123
+
+<HelloWorld />
+
+456
|