-
-
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.
test: add framework nesting e2e tests
- Loading branch information
Nate Moore
committed
May 27, 2022
1 parent
5bbd04c
commit 001731d
Showing
47 changed files
with
1,502 additions
and
10 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
12 changes: 12 additions & 0 deletions
12
packages/astro/e2e/fixtures/nested-in-preact/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,12 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import preact from '@astrojs/preact'; | ||
import react from '@astrojs/react'; | ||
import svelte from '@astrojs/svelte'; | ||
import vue from '@astrojs/vue'; | ||
import solid from '@astrojs/solid-js'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
// Enable many frameworks to support all different kinds of components. | ||
integrations: [preact(), react(), svelte(), vue(), solid()], | ||
}); |
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,21 @@ | ||
{ | ||
"name": "@e2e/nested-in-preact", | ||
"version": "0.0.0", | ||
"private": true, | ||
"devDependencies": { | ||
"@astrojs/preact": "^0.1.2", | ||
"@astrojs/react": "^0.1.2", | ||
"@astrojs/solid-js": "^0.1.2", | ||
"@astrojs/svelte": "^0.1.3", | ||
"@astrojs/vue": "^0.1.4", | ||
"astro": "^1.0.0-beta.32" | ||
}, | ||
"dependencies": { | ||
"preact": "^10.7.2", | ||
"react": "^18.1.0", | ||
"react-dom": "^18.1.0", | ||
"solid-js": "^1.4.2", | ||
"svelte": "^3.48.0", | ||
"vue": "^3.2.36" | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/astro/e2e/fixtures/nested-in-preact/src/components/PreactCounter.tsx
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,17 @@ | ||
import { useState } from 'preact/hooks'; | ||
|
||
/** a counter written in Preact */ | ||
export function PreactCounter({ children, id }) { | ||
const [count, setCount] = useState(0); | ||
const add = () => setCount((i) => i + 1); | ||
const subtract = () => setCount((i) => i - 1); | ||
|
||
return ( | ||
<div id={id} class="counter"> | ||
<button class="decrement" onClick={subtract}>-</button> | ||
<pre id={`${id}-count`}>{count}</pre> | ||
<button id={`${id}-increment`} class="increment" onClick={add}>+</button> | ||
<div class="children">{children}</div> | ||
</div> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/astro/e2e/fixtures/nested-in-preact/src/components/ReactCounter.jsx
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,17 @@ | ||
import { useState } from 'react'; | ||
|
||
/** a counter written in React */ | ||
export default function Counter({ children, id }) { | ||
const [count, setCount] = useState(0); | ||
const add = () => setCount((i) => i + 1); | ||
const subtract = () => setCount((i) => i - 1); | ||
|
||
return ( | ||
<div id={id} className="counter"> | ||
<button className="decrement" onClick={subtract}>-</button> | ||
<pre id={`${id}-count`}>{count}</pre> | ||
<button id={`${id}-increment`} className="increment" onClick={add}>+</button> | ||
<div className="children">{children}</div> | ||
</div> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/astro/e2e/fixtures/nested-in-preact/src/components/SolidCounter.tsx
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,17 @@ | ||
import { createSignal } from 'solid-js'; | ||
|
||
/** a counter written with Solid */ | ||
export default function SolidCounter({ children, id }) { | ||
const [count, setCount] = createSignal(0); | ||
const add = () => setCount(count() + 1); | ||
const subtract = () => setCount(count() - 1); | ||
|
||
return ( | ||
<div id={id} class="counter"> | ||
<button class="decrement" onClick={subtract}>-</button> | ||
<pre id={`${id}-count`}>{count()}</pre> | ||
<button id={`${id}-increment`} class="increment" onClick={add}>+</button> | ||
<div class="children">{children}</div> | ||
</div> | ||
); | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/astro/e2e/fixtures/nested-in-preact/src/components/SvelteCounter.svelte
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,29 @@ | ||
|
||
<script> | ||
export let id; | ||
let children; | ||
let count = 0; | ||
function add() { | ||
count += 1; | ||
} | ||
function subtract() { | ||
count -= 1; | ||
} | ||
</script> | ||
|
||
<div {id} class="counter"> | ||
<button class="decrement" on:click={subtract}>-</button> | ||
<pre id={`${id}-count`}>{ count }</pre> | ||
<button id={`${id}-increment`} class="increment" on:click={add}>+</button> | ||
<div class="children"> | ||
<slot /> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.counter { | ||
background: white; | ||
} | ||
</style> |
34 changes: 34 additions & 0 deletions
34
packages/astro/e2e/fixtures/nested-in-preact/src/components/VueCounter.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,34 @@ | ||
<template> | ||
<div :id="id" class="counter"> | ||
<button class="decrement" @click="subtract()">-</button> | ||
<pre :id="`${id}-count`">{{ count }}</pre> | ||
<button :id="`${id}-increment`" class="increment" @click="add()">+</button> | ||
<div class="children"> | ||
<slot /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { ref } from 'vue'; | ||
export default { | ||
props: { | ||
id: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
setup(props) { | ||
const count = ref(0); | ||
const add = () => (count.value = count.value + 1); | ||
const subtract = () => (count.value = count.value - 1); | ||
return { | ||
id: props.id, | ||
count, | ||
add, | ||
subtract, | ||
}; | ||
}, | ||
}; | ||
</script> |
28 changes: 28 additions & 0 deletions
28
packages/astro/e2e/fixtures/nested-in-preact/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,28 @@ | ||
--- | ||
import ReactCounter from '../components/ReactCounter.jsx'; | ||
import { PreactCounter } from '../components/PreactCounter.tsx'; | ||
import SolidCounter from '../components/SolidCounter.tsx'; | ||
import VueCounter from '../components/VueCounter.vue'; | ||
import SvelteCounter from '../components/SvelteCounter.svelte'; | ||
// Full Astro Component Syntax: | ||
// https://docs.astro.build/core-concepts/astro-components/ | ||
--- | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<link rel="icon" type="image/x-icon" href="/favicon.ico" /> | ||
</head> | ||
<body> | ||
<main> | ||
<PreactCounter id="preact-counter" client:load> | ||
<ReactCounter id="react-counter" client:load /> | ||
<SolidCounter id="solid-counter" client:load /> | ||
<SvelteCounter id="svelte-counter" client:load /> | ||
<VueCounter id="vue-counter" client:load /> | ||
</PreactCounter> | ||
</main> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
packages/astro/e2e/fixtures/nested-in-react/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,12 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import preact from '@astrojs/preact'; | ||
import react from '@astrojs/react'; | ||
import svelte from '@astrojs/svelte'; | ||
import vue from '@astrojs/vue'; | ||
import solid from '@astrojs/solid-js'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
// Enable many frameworks to support all different kinds of components. | ||
integrations: [preact(), react(), svelte(), vue(), solid()], | ||
}); |
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,21 @@ | ||
{ | ||
"name": "@e2e/nested-in-react", | ||
"version": "0.0.0", | ||
"private": true, | ||
"devDependencies": { | ||
"@astrojs/preact": "^0.1.2", | ||
"@astrojs/react": "^0.1.2", | ||
"@astrojs/solid-js": "^0.1.2", | ||
"@astrojs/svelte": "^0.1.3", | ||
"@astrojs/vue": "^0.1.4", | ||
"astro": "^1.0.0-beta.32" | ||
}, | ||
"dependencies": { | ||
"preact": "^10.7.2", | ||
"react": "^18.1.0", | ||
"react-dom": "^18.1.0", | ||
"solid-js": "^1.4.2", | ||
"svelte": "^3.48.0", | ||
"vue": "^3.2.36" | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/astro/e2e/fixtures/nested-in-react/src/components/PreactCounter.tsx
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,17 @@ | ||
import { useState } from 'preact/hooks'; | ||
|
||
/** a counter written in Preact */ | ||
export function PreactCounter({ children, id }) { | ||
const [count, setCount] = useState(0); | ||
const add = () => setCount((i) => i + 1); | ||
const subtract = () => setCount((i) => i - 1); | ||
|
||
return ( | ||
<div id={id} class="counter"> | ||
<button class="decrement" onClick={subtract}>-</button> | ||
<pre id={`${id}-count`}>{count}</pre> | ||
<button id={`${id}-increment`} class="increment" onClick={add}>+</button> | ||
<div class="children">{children}</div> | ||
</div> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/astro/e2e/fixtures/nested-in-react/src/components/ReactCounter.jsx
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,17 @@ | ||
import { useState } from 'react'; | ||
|
||
/** a counter written in React */ | ||
export default function Counter({ children, id }) { | ||
const [count, setCount] = useState(0); | ||
const add = () => setCount((i) => i + 1); | ||
const subtract = () => setCount((i) => i - 1); | ||
|
||
return ( | ||
<div id={id} className="counter"> | ||
<button className="decrement" onClick={subtract}>-</button> | ||
<pre id={`${id}-count`}>{count}</pre> | ||
<button id={`${id}-increment`} className="increment" onClick={add}>+</button> | ||
<div className="children">{children}</div> | ||
</div> | ||
); | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/astro/e2e/fixtures/nested-in-react/src/components/SolidCounter.tsx
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,17 @@ | ||
import { createSignal } from 'solid-js'; | ||
|
||
/** a counter written with Solid */ | ||
export default function SolidCounter({ children, id }) { | ||
const [count, setCount] = createSignal(0); | ||
const add = () => setCount(count() + 1); | ||
const subtract = () => setCount(count() - 1); | ||
|
||
return ( | ||
<div id={id} class="counter"> | ||
<button class="decrement" onClick={subtract}>-</button> | ||
<pre id={`${id}-count`}>{count()}</pre> | ||
<button id={`${id}-increment`} class="increment" onClick={add}>+</button> | ||
<div class="children">{children}</div> | ||
</div> | ||
); | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/astro/e2e/fixtures/nested-in-react/src/components/SvelteCounter.svelte
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,29 @@ | ||
|
||
<script> | ||
export let id; | ||
let children; | ||
let count = 0; | ||
function add() { | ||
count += 1; | ||
} | ||
function subtract() { | ||
count -= 1; | ||
} | ||
</script> | ||
|
||
<div {id} class="counter"> | ||
<button class="decrement" on:click={subtract}>-</button> | ||
<pre id={`${id}-count`}>{ count }</pre> | ||
<button id={`${id}-increment`} class="increment" on:click={add}>+</button> | ||
<div class="children"> | ||
<slot /> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.counter { | ||
background: white; | ||
} | ||
</style> |
34 changes: 34 additions & 0 deletions
34
packages/astro/e2e/fixtures/nested-in-react/src/components/VueCounter.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,34 @@ | ||
<template> | ||
<div :id="id" class="counter"> | ||
<button class="decrement" @click="subtract()">-</button> | ||
<pre :id="`${id}-count`">{{ count }}</pre> | ||
<button :id="`${id}-increment`" class="increment" @click="add()">+</button> | ||
<div class="children"> | ||
<slot /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { ref } from 'vue'; | ||
export default { | ||
props: { | ||
id: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
setup(props) { | ||
const count = ref(0); | ||
const add = () => (count.value = count.value + 1); | ||
const subtract = () => (count.value = count.value - 1); | ||
return { | ||
id: props.id, | ||
count, | ||
add, | ||
subtract, | ||
}; | ||
}, | ||
}; | ||
</script> |
28 changes: 28 additions & 0 deletions
28
packages/astro/e2e/fixtures/nested-in-react/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,28 @@ | ||
--- | ||
import ReactCounter from '../components/ReactCounter.jsx'; | ||
import { PreactCounter } from '../components/PreactCounter.tsx'; | ||
import SolidCounter from '../components/SolidCounter.tsx'; | ||
import VueCounter from '../components/VueCounter.vue'; | ||
import SvelteCounter from '../components/SvelteCounter.svelte'; | ||
// Full Astro Component Syntax: | ||
// https://docs.astro.build/core-concepts/astro-components/ | ||
--- | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<link rel="icon" type="image/x-icon" href="/favicon.ico" /> | ||
</head> | ||
<body> | ||
<main> | ||
<ReactCounter id="react-counter" client:load> | ||
<SolidCounter id="solid-counter" client:load /> | ||
<SvelteCounter id="svelte-counter" client:load /> | ||
<PreactCounter id="preact-counter" client:load /> | ||
<VueCounter id="vue-counter" client:load /> | ||
</ReactCounter> | ||
</main> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
packages/astro/e2e/fixtures/nested-in-solid/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,12 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import preact from '@astrojs/preact'; | ||
import react from '@astrojs/react'; | ||
import svelte from '@astrojs/svelte'; | ||
import vue from '@astrojs/vue'; | ||
import solid from '@astrojs/solid-js'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
// Enable many frameworks to support all different kinds of components. | ||
integrations: [preact(), react(), svelte(), vue(), solid()], | ||
}); |
Oops, something went wrong.