summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/astro-dynamic.test.js30
-rw-r--r--test/fixtures/astro-dynamic/astro/components/Counter.jsx9
-rw-r--r--test/fixtures/astro-dynamic/astro/pages/index.astro9
3 files changed, 48 insertions, 0 deletions
diff --git a/test/astro-dynamic.test.js b/test/astro-dynamic.test.js
new file mode 100644
index 000000000..41235b6ce
--- /dev/null
+++ b/test/astro-dynamic.test.js
@@ -0,0 +1,30 @@
+import { suite } from 'uvu';
+import * as assert from 'uvu/assert';
+import { doc } from './test-utils.js';
+import { setup } from './helpers.js';
+
+const DynamicComponents = suite('Dynamic components tests');
+
+setup(DynamicComponents, './fixtures/astro-dynamic');
+
+DynamicComponents('Loads client-only packages', async ({ runtime }) => {
+ let result = await runtime.load('/');
+
+ assert.equal(result.statusCode, 200);
+
+ // Grab the react-dom import
+ const exp = /import\("(.+?)"\)/g;
+ let match, reactDomURL;
+ while(match = exp.exec(result.contents)) {
+ if(match[1].includes('react-dom')) {
+ reactDomURL = match[1];
+ }
+ }
+
+ assert.ok(reactDomURL, 'React dom is on the page');
+
+ result = await runtime.load(reactDomURL);
+ assert.equal(result.statusCode, 200, 'Can load react-dom');
+});
+
+DynamicComponents.run();
diff --git a/test/fixtures/astro-dynamic/astro/components/Counter.jsx b/test/fixtures/astro-dynamic/astro/components/Counter.jsx
new file mode 100644
index 000000000..31472c3ac
--- /dev/null
+++ b/test/fixtures/astro-dynamic/astro/components/Counter.jsx
@@ -0,0 +1,9 @@
+import React from 'react';
+
+export default function() {
+ return (
+ <div>
+ <button type="button">Increment -</button>
+ </div>
+ )
+} \ No newline at end of file
diff --git a/test/fixtures/astro-dynamic/astro/pages/index.astro b/test/fixtures/astro-dynamic/astro/pages/index.astro
new file mode 100644
index 000000000..12932901f
--- /dev/null
+++ b/test/fixtures/astro-dynamic/astro/pages/index.astro
@@ -0,0 +1,9 @@
+---
+import Counter from '../components/Counter.jsx';
+---
+<html>
+<head><title>Dynamic pages</title></head>
+<body>
+ <Counter:load />
+</body>
+</html> \ No newline at end of file