aboutsummaryrefslogtreecommitdiff
path: root/packages/integrations/markdoc/test
diff options
context:
space:
mode:
authorGravatar Luca Di Gianventura <lucadig.1994@gmail.com> 2023-10-27 11:45:02 +0200
committerGravatar GitHub <noreply@github.com> 2023-10-27 17:45:02 +0800
commit01c801108f1f5429436e4fc930018bf96ed31f79 (patch)
tree8fd6273aebe6a19336cdce4c21f0411ffa7b3848 /packages/integrations/markdoc/test
parent35c5265dc2b1e5940e14eebc50c7ccff98fe5f3b (diff)
downloadastro-01c801108f1f5429436e4fc930018bf96ed31f79.tar.gz
astro-01c801108f1f5429436e4fc930018bf96ed31f79.tar.zst
astro-01c801108f1f5429436e4fc930018bf96ed31f79.zip
Fix: Markdoc Integration build when root folder contains spaces (#8759)
Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/markdoc/test')
-rw-r--r--packages/integrations/markdoc/test/fixtures/render with-space/astro.config.mjs7
-rw-r--r--packages/integrations/markdoc/test/fixtures/render with-space/package.json9
-rw-r--r--packages/integrations/markdoc/test/fixtures/render with-space/src/content/blog/simple.mdoc7
-rw-r--r--packages/integrations/markdoc/test/fixtures/render with-space/src/pages/index.astro19
-rw-r--r--packages/integrations/markdoc/test/render.test.js32
5 files changed, 74 insertions, 0 deletions
diff --git a/packages/integrations/markdoc/test/fixtures/render with-space/astro.config.mjs b/packages/integrations/markdoc/test/fixtures/render with-space/astro.config.mjs
new file mode 100644
index 000000000..29d846359
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render with-space/astro.config.mjs
@@ -0,0 +1,7 @@
+import { defineConfig } from 'astro/config';
+import markdoc from '@astrojs/markdoc';
+
+// https://astro.build/config
+export default defineConfig({
+ integrations: [markdoc()],
+});
diff --git a/packages/integrations/markdoc/test/fixtures/render with-space/package.json b/packages/integrations/markdoc/test/fixtures/render with-space/package.json
new file mode 100644
index 000000000..daae65443
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render with-space/package.json
@@ -0,0 +1,9 @@
+{
+ "name": "@test/markdoc-render-with-space",
+ "version": "0.0.0",
+ "private": true,
+ "dependencies": {
+ "@astrojs/markdoc": "workspace:*",
+ "astro": "workspace:*"
+ }
+}
diff --git a/packages/integrations/markdoc/test/fixtures/render with-space/src/content/blog/simple.mdoc b/packages/integrations/markdoc/test/fixtures/render with-space/src/content/blog/simple.mdoc
new file mode 100644
index 000000000..2dbe492fe
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render with-space/src/content/blog/simple.mdoc
@@ -0,0 +1,7 @@
+---
+title: Simple post with root folder containing a space
+---
+
+## Simple post with root folder containing a space
+
+This is a simple Markdoc post with root folder containing a space.
diff --git a/packages/integrations/markdoc/test/fixtures/render with-space/src/pages/index.astro b/packages/integrations/markdoc/test/fixtures/render with-space/src/pages/index.astro
new file mode 100644
index 000000000..940eef154
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render with-space/src/pages/index.astro
@@ -0,0 +1,19 @@
+---
+import { getEntryBySlug } from "astro:content";
+
+const post = await getEntryBySlug('blog', 'simple');
+const { Content } = await post.render();
+---
+
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Content</title>
+</head>
+<body>
+ <Content />
+</body>
+</html>
diff --git a/packages/integrations/markdoc/test/render.test.js b/packages/integrations/markdoc/test/render.test.js
index 3ac9c3ac4..f1760a8e6 100644
--- a/packages/integrations/markdoc/test/render.test.js
+++ b/packages/integrations/markdoc/test/render.test.js
@@ -69,6 +69,18 @@ describe('Markdoc - render', () => {
await server.stop();
});
+
+ it('renders content - with root folder containing space', async () => {
+ const fixture = await getFixture('render with-space');
+ const server = await fixture.startDevServer();
+
+ const res = await fixture.fetch('/');
+ const html = await res.text();
+
+ renderWithRootFolderContainingSpace(html);
+
+ await server.stop();
+ });
});
describe('build', () => {
@@ -116,6 +128,15 @@ describe('Markdoc - render', () => {
renderNullChecks(html);
});
+
+ it('renders content - with root folder containing space', async () => {
+ const fixture = await getFixture('render with-space');
+ await fixture.build();
+
+ const html = await fixture.readFile('/index.html');
+
+ renderWithRootFolderContainingSpace(html);
+ });
});
});
@@ -189,3 +210,14 @@ function renderSimpleChecks(html) {
const p = document.querySelector('p');
expect(p.textContent).to.equal('This is a simple Markdoc post.');
}
+
+/** @param {string} html */
+function renderWithRootFolderContainingSpace(html) {
+ const { document } = parseHTML(html);
+ const h2 = document.querySelector('h2');
+ expect(h2.textContent).to.equal('Simple post with root folder containing a space');
+ const p = document.querySelector('p');
+ expect(p.textContent).to.equal(
+ 'This is a simple Markdoc post with root folder containing a space.'
+ );
+}