summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@matthewphillips.info> 2021-04-06 16:14:42 -0400
committerGravatar GitHub <noreply@github.com> 2021-04-06 16:14:42 -0400
commit72d9ece6db9cd57c865108b5fad43cbd5728e204 (patch)
treefe9f3ada071ece00c642dba162779796b0be1da3 /test
parent7240f0d67737da3c003455d4ebed6faa5be8c118 (diff)
downloadastro-72d9ece6db9cd57c865108b5fad43cbd5728e204.tar.gz
astro-72d9ece6db9cd57c865108b5fad43cbd5728e204.tar.zst
astro-72d9ece6db9cd57c865108b5fad43cbd5728e204.zip
Compiler cleanup (#64)
* Compiler cleanup This is general compiler cleanup, especially around the codegen part. Goals here were too: 1. Make it possible to compile HTML recursively (needed for future astro-in-expressions work) by moving that work into its own function. 1. Get rid of collectionItems and have compiling the HTML return just a source string. Also not planned, this change gets rid of the different between components and pages. All Astro components compile to the same JavaScript. * Remove unused node types
Diffstat (limited to 'test')
-rw-r--r--test/astro-expr.test.js18
-rw-r--r--test/fixtures/astro-expr/astro.config.mjs6
-rw-r--r--test/fixtures/astro-expr/astro/components/Color.jsx5
-rw-r--r--test/fixtures/astro-expr/astro/pages/index.astro22
4 files changed, 51 insertions, 0 deletions
diff --git a/test/astro-expr.test.js b/test/astro-expr.test.js
new file mode 100644
index 000000000..c9aa414dd
--- /dev/null
+++ b/test/astro-expr.test.js
@@ -0,0 +1,18 @@
+import { suite } from 'uvu';
+import * as assert from 'uvu/assert';
+import { doc } from './test-utils.js';
+import { setup } from './helpers.js';
+
+const Expressions = suite('Expressions');
+
+setup(Expressions, './fixtures/astro-expr');
+
+Expressions('Can load page', async ({ runtime }) => {
+ const result = await runtime.load('/');
+
+ console.log(result)
+ assert.equal(result.statusCode, 200);
+ console.log(result.contents);
+});
+
+Expressions.run();
diff --git a/test/fixtures/astro-expr/astro.config.mjs b/test/fixtures/astro-expr/astro.config.mjs
new file mode 100644
index 000000000..80d0860c3
--- /dev/null
+++ b/test/fixtures/astro-expr/astro.config.mjs
@@ -0,0 +1,6 @@
+
+export default {
+ extensions: {
+ '.jsx': 'preact'
+ }
+} \ No newline at end of file
diff --git a/test/fixtures/astro-expr/astro/components/Color.jsx b/test/fixtures/astro-expr/astro/components/Color.jsx
new file mode 100644
index 000000000..13a5049aa
--- /dev/null
+++ b/test/fixtures/astro-expr/astro/components/Color.jsx
@@ -0,0 +1,5 @@
+import { h } from 'preact';
+
+export default function({ name }) {
+ return <div>{name}</div>
+} \ No newline at end of file
diff --git a/test/fixtures/astro-expr/astro/pages/index.astro b/test/fixtures/astro-expr/astro/pages/index.astro
new file mode 100644
index 000000000..f0a4d2ab0
--- /dev/null
+++ b/test/fixtures/astro-expr/astro/pages/index.astro
@@ -0,0 +1,22 @@
+---
+import Color from '../components/Color.jsx';
+
+let title = 'My Site';
+
+const colors = ['red', 'yellow', 'blue']
+---
+
+<html lang="en">
+<head>
+ <title>My site</title>
+</head>
+<body>
+ <h1>{title}</h1>
+
+ {colors.map(color => (
+ <div>
+ <Color name={color} />
+ </div>
+ ))}
+</body>
+</html> \ No newline at end of file