summaryrefslogtreecommitdiff
path: root/packages/integrations/react/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--packages/integrations/react/test/fixtures/react-component/astro.config.mjs (renamed from packages/astro/test/fixtures/react-component/astro.config.mjs)6
-rw-r--r--packages/integrations/react/test/fixtures/react-component/package.json (renamed from packages/astro/test/fixtures/react-component/package.json)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/ArrowFunction.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/ArrowFunction.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/CloneElement.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/CloneElement.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/ForgotImport.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/ForgotImport.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/GetSearch.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/GetSearch.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/Goodbye.vue (renamed from packages/astro/test/fixtures/react-component/src/components/Goodbye.vue)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/Hello.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/Hello.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/ImportsThrowsAnError.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/ImportsThrowsAnError.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/LazyComponent.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/LazyComponent.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/PragmaComment.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/PragmaComment.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/PragmaCommentTypeScript.tsx (renamed from packages/astro/test/fixtures/react-component/src/components/PragmaCommentTypeScript.tsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/PropsSpread.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/PropsSpread.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/Pure.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/Pure.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/Research.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/Research.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/Suspense.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/Suspense.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/ThrowsAnError.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/ThrowsAnError.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/TypeScriptComponent.tsx (renamed from packages/astro/test/fixtures/react-component/src/components/TypeScriptComponent.tsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/WithChildren.jsx10
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/components/WithId.jsx (renamed from packages/astro/test/fixtures/react-component/src/components/WithId.jsx)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/pages/children.astro14
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/pages/error-rendering.astro (renamed from packages/astro/test/fixtures/react-component/src/pages/error-rendering.astro)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/pages/index.astro (renamed from packages/astro/test/fixtures/react-component/src/pages/index.astro)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/pages/pragma-comment.astro (renamed from packages/astro/test/fixtures/react-component/src/pages/pragma-comment.astro)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/pages/suspense.astro (renamed from packages/astro/test/fixtures/react-component/src/pages/suspense.astro)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/skipped-pages/forgot-import.astro (renamed from packages/astro/test/fixtures/react-component/src/skipped-pages/forgot-import.astro)0
-rw-r--r--packages/integrations/react/test/fixtures/react-component/src/skipped-pages/window.astro (renamed from packages/astro/test/fixtures/react-component/src/skipped-pages/window.astro)0
-rw-r--r--packages/integrations/react/test/react-component.test.js (renamed from packages/astro/test/react-component.test.js)14
28 files changed, 38 insertions, 6 deletions
diff --git a/packages/astro/test/fixtures/react-component/astro.config.mjs b/packages/integrations/react/test/fixtures/react-component/astro.config.mjs
index 53d0bd03b..cd54d60f8 100644
--- a/packages/astro/test/fixtures/react-component/astro.config.mjs
+++ b/packages/integrations/react/test/fixtures/react-component/astro.config.mjs
@@ -4,5 +4,7 @@ import vue from '@astrojs/vue';
// https://astro.build/config
export default defineConfig({
- integrations: [react(), vue()],
-}); \ No newline at end of file
+ integrations: [react({
+ experimentalReactChildren: true,
+ }), vue()],
+});
diff --git a/packages/astro/test/fixtures/react-component/package.json b/packages/integrations/react/test/fixtures/react-component/package.json
index cf7b2b057..cf7b2b057 100644
--- a/packages/astro/test/fixtures/react-component/package.json
+++ b/packages/integrations/react/test/fixtures/react-component/package.json
diff --git a/packages/astro/test/fixtures/react-component/src/components/ArrowFunction.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/ArrowFunction.jsx
index 16fac5bb6..16fac5bb6 100644
--- a/packages/astro/test/fixtures/react-component/src/components/ArrowFunction.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/ArrowFunction.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/CloneElement.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/CloneElement.jsx
index 809ac4aa4..809ac4aa4 100644
--- a/packages/astro/test/fixtures/react-component/src/components/CloneElement.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/CloneElement.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/ForgotImport.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/ForgotImport.jsx
index 9ee27faca..9ee27faca 100644
--- a/packages/astro/test/fixtures/react-component/src/components/ForgotImport.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/ForgotImport.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/GetSearch.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/GetSearch.jsx
index d3fee2f9a..d3fee2f9a 100644
--- a/packages/astro/test/fixtures/react-component/src/components/GetSearch.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/GetSearch.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/Goodbye.vue b/packages/integrations/react/test/fixtures/react-component/src/components/Goodbye.vue
index 430dfdb71..430dfdb71 100644
--- a/packages/astro/test/fixtures/react-component/src/components/Goodbye.vue
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/Goodbye.vue
diff --git a/packages/astro/test/fixtures/react-component/src/components/Hello.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/Hello.jsx
index 4c241162d..4c241162d 100644
--- a/packages/astro/test/fixtures/react-component/src/components/Hello.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/Hello.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/ImportsThrowsAnError.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/ImportsThrowsAnError.jsx
index d6ff21dc3..d6ff21dc3 100644
--- a/packages/astro/test/fixtures/react-component/src/components/ImportsThrowsAnError.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/ImportsThrowsAnError.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/LazyComponent.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/LazyComponent.jsx
index b43aa36be..b43aa36be 100644
--- a/packages/astro/test/fixtures/react-component/src/components/LazyComponent.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/LazyComponent.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/PragmaComment.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/PragmaComment.jsx
index d8ea77810..d8ea77810 100644
--- a/packages/astro/test/fixtures/react-component/src/components/PragmaComment.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/PragmaComment.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/PragmaCommentTypeScript.tsx b/packages/integrations/react/test/fixtures/react-component/src/components/PragmaCommentTypeScript.tsx
index 9f2256fbf..9f2256fbf 100644
--- a/packages/astro/test/fixtures/react-component/src/components/PragmaCommentTypeScript.tsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/PragmaCommentTypeScript.tsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/PropsSpread.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/PropsSpread.jsx
index 044c2a019..044c2a019 100644
--- a/packages/astro/test/fixtures/react-component/src/components/PropsSpread.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/PropsSpread.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/Pure.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/Pure.jsx
index 6fae8613b..6fae8613b 100644
--- a/packages/astro/test/fixtures/react-component/src/components/Pure.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/Pure.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/Research.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/Research.jsx
index 9ab83e5f3..9ab83e5f3 100644
--- a/packages/astro/test/fixtures/react-component/src/components/Research.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/Research.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/Suspense.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/Suspense.jsx
index 87dc82625..87dc82625 100644
--- a/packages/astro/test/fixtures/react-component/src/components/Suspense.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/Suspense.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/ThrowsAnError.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/ThrowsAnError.jsx
index cf970e38c..cf970e38c 100644
--- a/packages/astro/test/fixtures/react-component/src/components/ThrowsAnError.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/ThrowsAnError.jsx
diff --git a/packages/astro/test/fixtures/react-component/src/components/TypeScriptComponent.tsx b/packages/integrations/react/test/fixtures/react-component/src/components/TypeScriptComponent.tsx
index bde96da84..bde96da84 100644
--- a/packages/astro/test/fixtures/react-component/src/components/TypeScriptComponent.tsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/TypeScriptComponent.tsx
diff --git a/packages/integrations/react/test/fixtures/react-component/src/components/WithChildren.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/WithChildren.jsx
new file mode 100644
index 000000000..500c0c694
--- /dev/null
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/WithChildren.jsx
@@ -0,0 +1,10 @@
+import React from 'react';
+
+export default function ({ children }) {
+ return (
+ <div>
+ <div className="with-children">{children}</div>
+ <div className="with-children-count">{children.length}</div>
+ </div>
+ );
+}
diff --git a/packages/astro/test/fixtures/react-component/src/components/WithId.jsx b/packages/integrations/react/test/fixtures/react-component/src/components/WithId.jsx
index 0abe91c72..0abe91c72 100644
--- a/packages/astro/test/fixtures/react-component/src/components/WithId.jsx
+++ b/packages/integrations/react/test/fixtures/react-component/src/components/WithId.jsx
diff --git a/packages/integrations/react/test/fixtures/react-component/src/pages/children.astro b/packages/integrations/react/test/fixtures/react-component/src/pages/children.astro
new file mode 100644
index 000000000..59595c266
--- /dev/null
+++ b/packages/integrations/react/test/fixtures/react-component/src/pages/children.astro
@@ -0,0 +1,14 @@
+---
+import WithChildren from '../components/WithChildren';
+---
+
+<html>
+ <head>
+ <!-- Head Stuff -->
+ </head>
+ <body>
+ <WithChildren>
+ <div>child 1</div><div>child 2</div>
+ </WithChildren>
+ </body>
+</html>
diff --git a/packages/astro/test/fixtures/react-component/src/pages/error-rendering.astro b/packages/integrations/react/test/fixtures/react-component/src/pages/error-rendering.astro
index 6984a6da5..6984a6da5 100644
--- a/packages/astro/test/fixtures/react-component/src/pages/error-rendering.astro
+++ b/packages/integrations/react/test/fixtures/react-component/src/pages/error-rendering.astro
diff --git a/packages/astro/test/fixtures/react-component/src/pages/index.astro b/packages/integrations/react/test/fixtures/react-component/src/pages/index.astro
index 3afd8233f..3afd8233f 100644
--- a/packages/astro/test/fixtures/react-component/src/pages/index.astro
+++ b/packages/integrations/react/test/fixtures/react-component/src/pages/index.astro
diff --git a/packages/astro/test/fixtures/react-component/src/pages/pragma-comment.astro b/packages/integrations/react/test/fixtures/react-component/src/pages/pragma-comment.astro
index b3ddba639..b3ddba639 100644
--- a/packages/astro/test/fixtures/react-component/src/pages/pragma-comment.astro
+++ b/packages/integrations/react/test/fixtures/react-component/src/pages/pragma-comment.astro
diff --git a/packages/astro/test/fixtures/react-component/src/pages/suspense.astro b/packages/integrations/react/test/fixtures/react-component/src/pages/suspense.astro
index 5a9d15644..5a9d15644 100644
--- a/packages/astro/test/fixtures/react-component/src/pages/suspense.astro
+++ b/packages/integrations/react/test/fixtures/react-component/src/pages/suspense.astro
diff --git a/packages/astro/test/fixtures/react-component/src/skipped-pages/forgot-import.astro b/packages/integrations/react/test/fixtures/react-component/src/skipped-pages/forgot-import.astro
index de5d319d9..de5d319d9 100644
--- a/packages/astro/test/fixtures/react-component/src/skipped-pages/forgot-import.astro
+++ b/packages/integrations/react/test/fixtures/react-component/src/skipped-pages/forgot-import.astro
diff --git a/packages/astro/test/fixtures/react-component/src/skipped-pages/window.astro b/packages/integrations/react/test/fixtures/react-component/src/skipped-pages/window.astro
index e780f3c44..e780f3c44 100644
--- a/packages/astro/test/fixtures/react-component/src/skipped-pages/window.astro
+++ b/packages/integrations/react/test/fixtures/react-component/src/skipped-pages/window.astro
diff --git a/packages/astro/test/react-component.test.js b/packages/integrations/react/test/react-component.test.js
index a6bb8cfae..da7fa018a 100644
--- a/packages/astro/test/react-component.test.js
+++ b/packages/integrations/react/test/react-component.test.js
@@ -1,13 +1,13 @@
import { expect } from 'chai';
import { load as cheerioLoad } from 'cheerio';
-import { isWindows, loadFixture } from './test-utils.js';
+import { isWindows, loadFixture } from '../../../astro/test/test-utils.js';
let fixture;
describe('React Components', () => {
before(async () => {
fixture = await loadFixture({
- root: './fixtures/react-component/',
+ root: new URL('./fixtures/react-component/', import.meta.url),
});
});
@@ -51,7 +51,7 @@ describe('React Components', () => {
// test 10: Should properly render children passed as props
const islandsWithChildren = $('.with-children');
expect(islandsWithChildren).to.have.lengthOf(2);
- expect($(islandsWithChildren[0]).html()).to.equal($(islandsWithChildren[1]).html());
+ expect($(islandsWithChildren[0]).html()).to.equal($(islandsWithChildren[1]).find('astro-slot').html());
// test 11: Should generate unique React.useId per island
const islandsWithId = $('.react-use-id');
@@ -99,12 +99,18 @@ describe('React Components', () => {
const $ = cheerioLoad(html);
expect($('#cloned').text()).to.equal('Cloned With Props');
});
+
+ it('Children are parsed as React components, can be manipulated', async () => {
+ const html = await fixture.readFile('/children/index.html');
+ const $ = cheerioLoad(html);
+ expect($(".with-children-count").text()).to.equal('2');
+ })
});
if (isWindows) return;
describe('dev', () => {
- /** @type {import('./test-utils').Fixture} */
+ /** @type {import('../../../astro/test/test-utils.js').Fixture} */
let devServer;
before(async () => {