summaryrefslogtreecommitdiff
path: root/packages/integrations/markdoc/test
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/markdoc/test')
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-with-components/src/content/blog/with-components.mdoc9
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-with-extends-components/src/content/blog/with-components.mdoc9
-rw-r--r--packages/integrations/markdoc/test/render-components.test.js5
-rw-r--r--packages/integrations/markdoc/test/render-extends-components.test.js5
-rw-r--r--packages/integrations/markdoc/test/syntax-highlighting.test.js21
5 files changed, 49 insertions, 0 deletions
diff --git a/packages/integrations/markdoc/test/fixtures/render-with-components/src/content/blog/with-components.mdoc b/packages/integrations/markdoc/test/fixtures/render-with-components/src/content/blog/with-components.mdoc
index eb7d20426..0d1ec835c 100644
--- a/packages/integrations/markdoc/test/fixtures/render-with-components/src/content/blog/with-components.mdoc
+++ b/packages/integrations/markdoc/test/fixtures/render-with-components/src/content/blog/with-components.mdoc
@@ -17,3 +17,12 @@ And a code component for code blocks:
```js
const isRenderedWithShiki = true;
```
+
+{% if equals("true", "true") %}
+Inside truthy
+
+```js
+const isRenderedWithShikiInside = true;
+```
+
+{% /if %}
diff --git a/packages/integrations/markdoc/test/fixtures/render-with-extends-components/src/content/blog/with-components.mdoc b/packages/integrations/markdoc/test/fixtures/render-with-extends-components/src/content/blog/with-components.mdoc
index 61f404a97..8ff944b06 100644
--- a/packages/integrations/markdoc/test/fixtures/render-with-extends-components/src/content/blog/with-components.mdoc
+++ b/packages/integrations/markdoc/test/fixtures/render-with-extends-components/src/content/blog/with-components.mdoc
@@ -15,3 +15,12 @@ And a code component for code blocks:
```js
const isRenderedWithShiki = true;
```
+
+{% if equals("true", "true") %}
+Inside truthy
+
+```js
+const isRenderedWithShikiInside = true;
+```
+
+{% /if %}
diff --git a/packages/integrations/markdoc/test/render-components.test.js b/packages/integrations/markdoc/test/render-components.test.js
index b9ac8770f..e8ddec909 100644
--- a/packages/integrations/markdoc/test/render-components.test.js
+++ b/packages/integrations/markdoc/test/render-components.test.js
@@ -74,6 +74,11 @@ function renderComponentsChecks(html) {
const pre = document.querySelector('pre');
assert.notEqual(pre, null);
assert.equal(pre.className, 'astro-code github-dark');
+
+ // Renders 2nd Astro Code component inside if tag
+ const pre2 = document.querySelectorAll('pre')[1];
+ assert.notEqual(pre2, null);
+ assert.equal(pre2.className, 'astro-code github-dark');
}
/** @param {string} html */
diff --git a/packages/integrations/markdoc/test/render-extends-components.test.js b/packages/integrations/markdoc/test/render-extends-components.test.js
index 8d1778d3e..f5f1454c8 100644
--- a/packages/integrations/markdoc/test/render-extends-components.test.js
+++ b/packages/integrations/markdoc/test/render-extends-components.test.js
@@ -61,4 +61,9 @@ function renderComponentsChecks(html) {
const pre = document.querySelector('pre');
assert.notEqual(pre, null);
assert.equal(pre.className, 'astro-code github-dark');
+
+ // Renders 2nd Astro Code component inside if tag
+ const pre2 = document.querySelectorAll('pre')[1];
+ assert.notEqual(pre2, null);
+ assert.equal(pre2.className, 'astro-code github-dark');
}
diff --git a/packages/integrations/markdoc/test/syntax-highlighting.test.js b/packages/integrations/markdoc/test/syntax-highlighting.test.js
index f47b891f4..6ea841ae1 100644
--- a/packages/integrations/markdoc/test/syntax-highlighting.test.js
+++ b/packages/integrations/markdoc/test/syntax-highlighting.test.js
@@ -68,6 +68,27 @@ describe('Markdoc - syntax highlighting', () => {
assert.equal(pre.getAttribute('style').includes('word-wrap: break-word'), true);
}
});
+ it('transform within if tags', async () => {
+ const ast = Markdoc.parse(`
+{% if equals("true", "true") %}
+Inside truthy
+
+\`\`\`js
+const hello = "yes";
+\`\`\`
+
+{% /if %}`);
+ const content = await Markdoc.transform(ast, await getConfigExtendingShiki());
+ assert.equal(content.children.length, 1);
+ assert.equal(content.children[0].length, 2);
+ const pTag = content.children[0][0];
+ assert.equal(pTag.name, 'p');
+ const codeBlock = content.children[0][1];
+ assert.equal(isHTMLString(codeBlock), true);
+ const pre = parsePreTag(codeBlock);
+ assert.equal(pre.classList.contains('astro-code'), true);
+ assert.equal(pre.classList.contains('github-dark'), true);
+ });
});
describe('prism', () => {