-
-
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.
* fix miss a head when the templaterender has a promise * fix * add some test * test files move to md directory * fix add * delect file --------- Co-authored-by: wuls <[email protected]>
- Loading branch information
1 parent
29da199
commit cf62134
Showing
10 changed files
with
138 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,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
fix miss a head when the templaterender has a promise |
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
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,46 @@ | ||
import { expect } from 'chai'; | ||
import * as cheerio from 'cheerio'; | ||
import { loadFixture } from '../../../astro/test/test-utils.js'; | ||
import mdx from '@astrojs/mdx'; | ||
|
||
describe('build css from the component', async () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ root: new URL('./fixtures/astro-content-css/', import.meta.url),integrations: [mdx()], }); | ||
await fixture.build(); | ||
}); | ||
|
||
describe('Build', () => { | ||
before(async () => { | ||
await fixture.build(); | ||
}); | ||
|
||
it('including css and js from the component in pro', async () => { | ||
const html = await fixture.readFile('/index.html'); | ||
const $ = cheerio.load(html); | ||
expect($('link[href$=".css"]').attr('href')).to.match(/^\/_astro\//); | ||
expect($('script[src$=".js"]').attr('src')).to.match(/^\/_astro\//); | ||
}); | ||
}) | ||
|
||
describe('Dev', () => { | ||
let devServer | ||
before(async () => { | ||
devServer = await fixture.startDevServer(); | ||
}); | ||
|
||
after(async () => { | ||
devServer.stop(); | ||
}); | ||
|
||
it('ncluding css and js from the component in Dev', async () => { | ||
let res = await fixture.fetch(`/`); | ||
expect(res.status).to.equal(200); | ||
const html = await res.text(); | ||
const $ = cheerio.load(html); | ||
expect($.html()).to.include('CornflowerBlue'); | ||
expect($('script[src$=".js"]').attr('src')).to.include('astro'); | ||
}); | ||
}) | ||
}) |
11 changes: 11 additions & 0 deletions
11
packages/integrations/mdx/test/fixtures/astro-content-css/astro.config.mjs
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 @@ | ||
import { defineConfig } from 'astro/config'; | ||
|
||
import mdx from "@astrojs/mdx"; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
build: { | ||
format: 'file' | ||
}, | ||
integrations: [mdx()] | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/integrations/mdx/test/fixtures/astro-content-css/package.json
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,9 @@ | ||
{ | ||
"name": "@test/astro-content-css", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/mdx": "workspace:*" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/integrations/mdx/test/fixtures/astro-content-css/src/content/config.ts
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,12 @@ | ||
// 1. Import utilities from `astro:content` | ||
import { z, defineCollection } from 'astro:content'; | ||
// 2. Define a schema for each collection you'd like to validate. | ||
const dynamicCollection = defineCollection({ | ||
schema: z.object({ | ||
title: z.string(), | ||
}), | ||
}); | ||
// 3. Export a single `collections` object to register your collection(s) | ||
export const collections = { | ||
dynamic: dynamicCollection, | ||
}; |
18 changes: 18 additions & 0 deletions
18
...ations/mdx/test/fixtures/astro-content-css/src/content/dynamic/FirstComponentWithJS.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,18 @@ | ||
--- | ||
const { text } = Astro.props; | ||
--- | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head><meta charset="utf-8" /></head> | ||
<body> | ||
<div id="first">1st components with js. Props: {text}. <span>Styles</span>. JS: </div> | ||
</body> | ||
</html> | ||
<script> | ||
document.querySelector('#first').innerHTML += 'works'; | ||
</script> | ||
<style> | ||
#first > span { | ||
color: CornflowerBlue; | ||
} | ||
</style> |
9 changes: 9 additions & 0 deletions
9
...test/fixtures/astro-content-css/src/content/dynamic/first-component-with-js.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,9 @@ | ||
--- | ||
title: 'First component' | ||
--- | ||
|
||
import FirstDynamicComponentWithJS from './FirstComponentWithJS.astro'; | ||
|
||
<FirstDynamicComponentWithJS text={props.mdProps} /> | ||
|
||
Additional text from mdx 'first-component-with-js' |
16 changes: 16 additions & 0 deletions
16
packages/integrations/mdx/test/fixtures/astro-content-css/src/pages/index.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,16 @@ | ||
--- | ||
import { getCollection } from 'astro:content'; | ||
const entries = await getCollection('dynamic'); | ||
--- | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head><meta charset="utf-8" /></head> | ||
<body> | ||
{entries.map(async entry => { | ||
const { Content } = await entry.render(); | ||
return <Content mdProps="work" />; | ||
})} | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.