summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/hmx-basic/astro.config.mjs6
-rw-r--r--test/fixtures/hmx-basic/astro/pages/index.hmx15
-rw-r--r--test/fixtures/hmx-basic/snowpack.config.js5
-rw-r--r--test/hmx-basic.test.js38
-rw-r--r--test/test-utils.js5
5 files changed, 69 insertions, 0 deletions
diff --git a/test/fixtures/hmx-basic/astro.config.mjs b/test/fixtures/hmx-basic/astro.config.mjs
new file mode 100644
index 000000000..dbe6dc0ac
--- /dev/null
+++ b/test/fixtures/hmx-basic/astro.config.mjs
@@ -0,0 +1,6 @@
+
+export default {
+ projectRoot: '.',
+ hmxRoot: './astro',
+ dist: './_site'
+} \ No newline at end of file
diff --git a/test/fixtures/hmx-basic/astro/pages/index.hmx b/test/fixtures/hmx-basic/astro/pages/index.hmx
new file mode 100644
index 000000000..a8ea2678a
--- /dev/null
+++ b/test/fixtures/hmx-basic/astro/pages/index.hmx
@@ -0,0 +1,15 @@
+<script hmx="setup">
+ export function setup() {
+ return {
+ props: {}
+ }
+ }
+</script>
+
+<head>
+ <!-- Head Stuff -->
+</head>
+
+<body>
+ <h1>Hello world!</h1>
+</body> \ No newline at end of file
diff --git a/test/fixtures/hmx-basic/snowpack.config.js b/test/fixtures/hmx-basic/snowpack.config.js
new file mode 100644
index 000000000..2cbf0ef07
--- /dev/null
+++ b/test/fixtures/hmx-basic/snowpack.config.js
@@ -0,0 +1,5 @@
+export default {
+ mount: {
+
+ }
+};
diff --git a/test/hmx-basic.test.js b/test/hmx-basic.test.js
new file mode 100644
index 000000000..224ce07b3
--- /dev/null
+++ b/test/hmx-basic.test.js
@@ -0,0 +1,38 @@
+import { suite } from 'uvu';
+import * as assert from 'uvu/assert';
+import { createRuntime } from '../lib/runtime.js';
+import { doc } from './test-utils.js';
+
+const Basics = suite('HMX Basics');
+
+let runtime;
+
+Basics.before(async () => {
+ const astroConfig = {
+ projectRoot: new URL('./fixtures/hmx-basic/', import.meta.url),
+ hmxRoot: new URL('./fixtures/hmx-basic/astro/', import.meta.url),
+ dist: './_site'
+ };
+
+ const logging = {
+ level: 'error',
+ dest: process.stderr
+ };
+
+ runtime = await createRuntime(astroConfig, logging);
+});
+
+Basics.after(async () => {
+ await runtime.shutdown();
+});
+
+Basics('Can load hmx page', async () => {
+ const result = await runtime.load('/');
+
+ assert.equal(result.statusCode, 200);
+ const $ = doc(result.contents);
+
+ assert.equal($('h1').text(), 'Hello world!');
+});
+
+Basics.run(); \ No newline at end of file
diff --git a/test/test-utils.js b/test/test-utils.js
new file mode 100644
index 000000000..80241d6f5
--- /dev/null
+++ b/test/test-utils.js
@@ -0,0 +1,5 @@
+import cheerio from 'cheerio';
+
+export function doc(html) {
+ return cheerio.load(html);
+} \ No newline at end of file