-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/integrations/mdx/test/fixtures/css-head-mdx/src/components/HelloWorld.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
--- | ||
|
||
<h3>Hello world!!</h3> | ||
<slot /> | ||
|
||
<style>h3 { color: red }</style> | ||
|
||
<script> | ||
console.log('hellooooo') | ||
</script> |
15 changes: 15 additions & 0 deletions
15
packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/One.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
6 changes: 6 additions & 0 deletions
6
packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/Three.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
import Two from './Two.astro' | ||
--- | ||
<Two> | ||
<slot /> | ||
</Two> |
6 changes: 6 additions & 0 deletions
6
packages/integrations/mdx/test/fixtures/css-head-mdx/src/layouts/Two.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
import One from './One.astro' | ||
--- | ||
<One> | ||
<slot /> | ||
</One> |
10 changes: 10 additions & 0 deletions
10
packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexOne.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
import One from '../layouts/One.astro' | ||
import { Content } from '../test.mdx' | ||
--- | ||
|
||
<One> | ||
<h1>Astro</h1> | ||
<Content /> | ||
</One> |
10 changes: 10 additions & 0 deletions
10
packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexThree.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
import Three from '../layouts/Three.astro' | ||
import { Content } from '../test.mdx' | ||
--- | ||
|
||
<Three> | ||
<h1>Astro</h1> | ||
<Content /> | ||
</Three> |
10 changes: 10 additions & 0 deletions
10
packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/indexTwo.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
import Two from '../layouts/Two.astro' | ||
import { Content } from '../test.mdx' | ||
--- | ||
|
||
<Two> | ||
<h1>Astro</h1> | ||
<Content /> | ||
</Two> |
15 changes: 15 additions & 0 deletions
15
packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testOne.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
15 changes: 15 additions & 0 deletions
15
packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testThree.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
15 changes: 15 additions & 0 deletions
15
packages/integrations/mdx/test/fixtures/css-head-mdx/src/pages/testTwo.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
14 changes: 14 additions & 0 deletions
14
packages/integrations/mdx/test/fixtures/css-head-mdx/src/test.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: "hello world" | ||
publishDate: "2023-01-01" | ||
--- | ||
|
||
import HelloWorld from './components/HelloWorld.astro'; | ||
|
||
# Test | ||
|
||
123 | ||
|
||
<HelloWorld /> | ||
|
||
456 |