aboutsummaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/test/mdx-astro-markdown-remarkRehype.test.js
diff options
context:
space:
mode:
authorGravatar github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> 2025-06-05 14:25:23 +0000
committerGravatar github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> 2025-06-05 14:25:23 +0000
commite586d7d704d475afe3373a1de6ae20d504f79d6d (patch)
tree7e3fa24807cebd48a86bd40f866d792181191ee9 /packages/integrations/mdx/test/mdx-astro-markdown-remarkRehype.test.js
downloadastro-latest.tar.gz
astro-latest.tar.zst
astro-latest.zip
Sync from a8e1c0a7402940e0fc5beef669522b315052df1blatest
Diffstat (limited to 'packages/integrations/mdx/test/mdx-astro-markdown-remarkRehype.test.js')
-rw-r--r--packages/integrations/mdx/test/mdx-astro-markdown-remarkRehype.test.js89
1 files changed, 89 insertions, 0 deletions
diff --git a/packages/integrations/mdx/test/mdx-astro-markdown-remarkRehype.test.js b/packages/integrations/mdx/test/mdx-astro-markdown-remarkRehype.test.js
new file mode 100644
index 000000000..07197e0e5
--- /dev/null
+++ b/packages/integrations/mdx/test/mdx-astro-markdown-remarkRehype.test.js
@@ -0,0 +1,89 @@
+import mdx from '@astrojs/mdx';
+
+import * as assert from 'node:assert/strict';
+import { describe, it } from 'node:test';
+import { parseHTML } from 'linkedom';
+import { loadFixture } from '../../../astro/test/test-utils.js';
+
+describe('MDX with Astro Markdown remark-rehype config', () => {
+ it('Renders footnotes with values from the default configuration', async () => {
+ const fixture = await loadFixture({
+ root: new URL('./fixtures/mdx-astro-markdown-remarkRehype/', import.meta.url),
+ integrations: [mdx()],
+ markdown: {
+ remarkRehype: {
+ footnoteLabel: 'Catatan kaki',
+ footnoteBackLabel: 'Kembali ke konten',
+ },
+ },
+ });
+
+ await fixture.build();
+ const html = await fixture.readFile('/index.html');
+ const { document } = parseHTML(html);
+
+ assert.equal(document.querySelector('#footnote-label').textContent, 'Catatan kaki');
+ assert.equal(
+ document.querySelector('.data-footnote-backref').getAttribute('aria-label'),
+ 'Kembali ke konten',
+ );
+ });
+
+ it('Renders footnotes with values from custom configuration extending the default', async () => {
+ const fixture = await loadFixture({
+ root: new URL('./fixtures/mdx-astro-markdown-remarkRehype/', import.meta.url),
+ integrations: [
+ mdx({
+ remarkRehype: {
+ footnoteLabel: 'Catatan kaki',
+ footnoteBackLabel: 'Kembali ke konten',
+ },
+ }),
+ ],
+ markdown: {
+ remarkRehype: {
+ footnoteBackLabel: 'Replace me',
+ },
+ },
+ });
+
+ await fixture.build();
+ const html = await fixture.readFile('/index.html');
+ const { document } = parseHTML(html);
+
+ assert.equal(document.querySelector('#footnote-label').textContent, 'Catatan kaki');
+ assert.equal(
+ document.querySelector('.data-footnote-backref').getAttribute('aria-label'),
+ 'Kembali ke konten',
+ );
+ });
+
+ it('Renders footnotes with values from custom configuration without extending the default', async () => {
+ const fixture = await loadFixture({
+ root: new URL('./fixtures/mdx-astro-markdown-remarkRehype/', import.meta.url),
+ integrations: [
+ mdx({
+ extendPlugins: 'astroDefaults',
+ remarkRehype: {
+ footnoteLabel: 'Catatan kaki',
+ },
+ }),
+ ],
+ markdown: {
+ remarkRehype: {
+ footnoteBackLabel: 'Kembali ke konten',
+ },
+ },
+ });
+
+ await fixture.build();
+ const html = await fixture.readFile('/index.html');
+ const { document } = parseHTML(html);
+
+ assert.equal(document.querySelector('#footnote-label').textContent, 'Catatan kaki');
+ assert.equal(
+ document.querySelector('.data-footnote-backref').getAttribute('aria-label'),
+ 'Back to reference 1',
+ );
+ });
+});