forked from laptou/astro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tests for legacy build (withastro#2746)
* move fast-build example into a test fixture for legacy build * update tests for legacy build
- Loading branch information
1 parent
f1e7093
commit 9a56e76
Showing
16 changed files
with
181 additions
and
12 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
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,4 @@ | ||
// @ts-check | ||
export default /** @type {import('astro').AstroUserConfig} */ ({ | ||
renderers: ['@astrojs/renderer-vue'], | ||
}); |
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 @@ | ||
{ | ||
"name": "@astrojs/legacy-build", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/renderer-vue": "^0.4.0", | ||
"astro": "workspace:*", | ||
"preact": "~10.6.5" | ||
} | ||
} |
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,24 @@ | ||
<template> | ||
<div id="vue" class="counter"> | ||
<button @click="subtract()">-</button> | ||
<pre>{{ count }}</pre> | ||
<button @click="add()">+</button> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { ref } from 'vue'; | ||
export default { | ||
setup() { | ||
const count = ref(0); | ||
const add = () => (count.value = count.value + 1); | ||
const subtract = () => (count.value = count.value - 1); | ||
return { | ||
count, | ||
add, | ||
subtract, | ||
}; | ||
}, | ||
}; | ||
</script> |
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,20 @@ | ||
<script> | ||
export default { | ||
data() { | ||
return { | ||
greeting: 'Hello World!', | ||
}; | ||
}, | ||
}; | ||
</script> | ||
|
||
<template> | ||
<p class="greeting">{{ greeting }}</p> | ||
</template> | ||
|
||
<style> | ||
.greeting { | ||
color: red; | ||
font-weight: bold; | ||
} | ||
</style> |
13 changes: 13 additions & 0 deletions
13
test/fixtures/legacy-build/src/components/InlineHoisted.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,13 @@ | ||
<script type="module" hoist> | ||
import { h, render } from 'preact'; | ||
|
||
|
||
const mount = document.querySelector('#inline-hoist'); | ||
|
||
function App() { | ||
return h('strong', null, 'Hello again'); | ||
} | ||
|
||
render(h(App), mount); | ||
</script> | ||
<div id="inline-hoist"></div> |
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 @@ | ||
--- | ||
import Greeting from '../components/Greeting.vue'; | ||
export async function getStaticPaths() { | ||
const allPokemon = [{name: 'Charmander'}, {name: 'Charmander'}, {name: 'Charizard'}]; | ||
return allPokemon.map(pokemon => ({params: {pokemon: pokemon.name}, props: {pokemon}})); | ||
} | ||
--- | ||
<html lang="en"> | ||
<head> | ||
<title>Hello</title> | ||
</head> | ||
|
||
<body> | ||
<h1>{Astro.props.pokemon.name}</h1> | ||
<Greeting client:load /> | ||
</body> | ||
</html> |
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,60 @@ | ||
--- | ||
import Greeting from '../components/Greeting.vue'; | ||
import Counter from '../components/Counter.vue'; | ||
import InlineHoisted from '../components/InlineHoisted.astro'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>Demo app</title> | ||
<style> | ||
h1 { | ||
color: salmon; | ||
} | ||
</style> | ||
<style lang="scss"> | ||
@import "../styles/_global.scss"; | ||
h2 { | ||
color: $color; | ||
} | ||
</style> | ||
<style define:vars={{ color: 'blue' }}> | ||
.define-vars h1 { | ||
color: var(--color); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<section> | ||
<h1>Component CSS</h1> | ||
<Greeting /> | ||
</section> | ||
|
||
<section> | ||
<h1>ImageTools</h1> | ||
</section> | ||
|
||
<section> | ||
<h1>Astro components</h1> | ||
</section> | ||
|
||
<section> | ||
<h1>Hydrated component</h1> | ||
<Counter client:idle /> | ||
</section> | ||
|
||
<section> | ||
<h1>Hoisted scripts</h1> | ||
<InlineHoisted /> | ||
</section> | ||
|
||
<section class="define-vars"> | ||
<h1>define:vars</h1> | ||
<h2></h2> | ||
<script define:vars={{ color: 'blue' }}> | ||
document.querySelector('.define-vars h2').textContent = `Color: ${color}`; | ||
</script> | ||
</section> | ||
</body> | ||
</html> |
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,2 @@ | ||
const el = document.querySelector('#external-hoist'); | ||
el.textContent = `This was loaded externally`; |
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 @@ | ||
$color: tan; |
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,3 @@ | ||
body { | ||
background: lightcoral; | ||
} |
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,23 @@ | ||
import { expect } from 'chai'; | ||
import cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
describe('Legacy Build', () => { | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
projectRoot: './fixtures/legacy-build/', | ||
}); | ||
await fixture.build({buildOptions: {legacyBuild: true}}); | ||
}); | ||
|
||
describe('build', () => { | ||
it('is successful', async () => { | ||
const html = await fixture.readFile(`/index.html`); | ||
const $ = cheerio.load(html); | ||
expect($('title').text()).to.equal('Demo app'); | ||
}); | ||
|
||
}); | ||
}); |
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
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