summaryrefslogtreecommitdiff
path: root/test/hmx-markdown.test.js
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@matthewphillips.info> 2021-03-23 15:20:03 -0400
committerGravatar GitHub <noreply@github.com> 2021-03-23 15:20:03 -0400
commited85702581cad3f00729f920036560da439e1189 (patch)
tree96da9ef8e21d2dfaebc3c1c10120c0ffc6da802a /test/hmx-markdown.test.js
parente0353d50e77039bdf73d178a1d09dcd1aa0f59d0 (diff)
downloadastro-ed85702581cad3f00729f920036560da439e1189.tar.gz
astro-ed85702581cad3f00729f920036560da439e1189.tar.zst
astro-ed85702581cad3f00729f920036560da439e1189.zip
Allow HMX components in markdown (#19)
* Allow HMX components in markdown This adds support for HMX components in markdown. The mechanism for importing is via frontmatter. We could do this differently (setup script maybe?) but since this was the easiest to implement I thought it was a good first-pass option. * Remove node-fetch from snowpack config * Assert that the runtime is created successfully * Add back in the micromark extension for encoding entities * Encode both codeTextData and codeFlowValue * Install snowpack app's deps
Diffstat (limited to 'test/hmx-markdown.test.js')
-rw-r--r--test/hmx-markdown.test.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/hmx-markdown.test.js b/test/hmx-markdown.test.js
new file mode 100644
index 000000000..1a3a2e11c
--- /dev/null
+++ b/test/hmx-markdown.test.js
@@ -0,0 +1,45 @@
+import { suite } from 'uvu';
+import * as assert from 'uvu/assert';
+import { createRuntime } from '../lib/runtime.js';
+import { loadConfig } from '../lib/config.js';
+import { doc } from './test-utils.js';
+
+const HMXMD = suite('HMX Markdown');
+
+let runtime, setupError;
+
+HMXMD.before(async () => {
+ const astroConfig = await loadConfig(new URL('./fixtures/hmx-markdown', import.meta.url).pathname);
+
+ const logging = {
+ level: 'error',
+ dest: process.stderr
+ };
+
+ try {
+ runtime = await createRuntime(astroConfig, logging);
+ } catch(err) {
+ console.error(err);
+ setupError = err;
+ }
+});
+
+HMXMD.after(async () => {
+ runtime && runtime.shutdown();
+});
+
+HMXMD('No errors creating a runtime', () => {
+ assert.equal(setupError, undefined);
+});
+
+HMXMD('Can load markdown pages with hmx', async () => {
+ const result = await runtime.load('/post');
+
+ assert.equal(result.statusCode, 200);
+
+ const $ = doc(result.contents);
+ assert.ok($('#first').length, 'There is a div added in markdown');
+ assert.ok($('#test').length, 'There is a div added via a component from markdown');
+});
+
+HMXMD.run(); \ No newline at end of file