test: add test case for root folder with space
This commit is contained in:
parent
110d0306b0
commit
a763b0387e
5 changed files with 74 additions and 0 deletions
7
packages/integrations/markdoc/test/fixtures/render with-space/astro.config.mjs
vendored
Normal file
7
packages/integrations/markdoc/test/fixtures/render with-space/astro.config.mjs
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { defineConfig } from 'astro/config';
|
||||
import markdoc from '@astrojs/markdoc';
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
integrations: [markdoc()],
|
||||
});
|
9
packages/integrations/markdoc/test/fixtures/render with-space/package.json
vendored
Normal file
9
packages/integrations/markdoc/test/fixtures/render with-space/package.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@test/markdoc-render-with-space",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@astrojs/markdoc": "workspace:*",
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
7
packages/integrations/markdoc/test/fixtures/render with-space/src/content/blog/simple.mdoc
vendored
Normal file
7
packages/integrations/markdoc/test/fixtures/render with-space/src/content/blog/simple.mdoc
vendored
Normal file
|
@ -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.
|
19
packages/integrations/markdoc/test/fixtures/render with-space/src/pages/index.astro
vendored
Normal file
19
packages/integrations/markdoc/test/fixtures/render with-space/src/pages/index.astro
vendored
Normal file
|
@ -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>
|
|
@ -57,6 +57,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', () => {
|
||||
|
@ -95,6 +107,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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -148,3 +169,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.'
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue