2022-11-22 10:12:25 -05:00
|
|
|
import mdx from '@astrojs/mdx';
|
|
|
|
|
2024-01-31 03:37:34 -05:00
|
|
|
import { describe, it } from 'node:test';
|
|
|
|
import * as assert from 'node:assert/strict';
|
2022-11-22 10:12:25 -05:00
|
|
|
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);
|
|
|
|
|
2024-01-31 03:37:34 -05:00
|
|
|
assert.equal(document.querySelector('#footnote-label').textContent, 'Catatan kaki');
|
|
|
|
assert.equal(
|
|
|
|
document.querySelector('.data-footnote-backref').getAttribute('aria-label'),
|
2022-11-22 10:12:25 -05:00
|
|
|
'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),
|
2022-11-22 10:15:03 -05:00
|
|
|
integrations: [
|
|
|
|
mdx({
|
|
|
|
remarkRehype: {
|
|
|
|
footnoteLabel: 'Catatan kaki',
|
|
|
|
footnoteBackLabel: 'Kembali ke konten',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
2022-11-22 10:12:25 -05:00
|
|
|
markdown: {
|
|
|
|
remarkRehype: {
|
|
|
|
footnoteBackLabel: 'Replace me',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
await fixture.build();
|
|
|
|
const html = await fixture.readFile('/index.html');
|
|
|
|
const { document } = parseHTML(html);
|
|
|
|
|
2024-01-31 03:37:34 -05:00
|
|
|
assert.equal(document.querySelector('#footnote-label').textContent, 'Catatan kaki');
|
|
|
|
assert.equal(
|
|
|
|
document.querySelector('.data-footnote-backref').getAttribute('aria-label'),
|
2022-11-22 10:12:25 -05:00
|
|
|
'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),
|
2022-11-22 10:15:03 -05:00
|
|
|
integrations: [
|
|
|
|
mdx({
|
|
|
|
extendPlugins: 'astroDefaults',
|
|
|
|
remarkRehype: {
|
|
|
|
footnoteLabel: 'Catatan kaki',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
2022-11-22 10:12:25 -05:00
|
|
|
markdown: {
|
|
|
|
remarkRehype: {
|
|
|
|
footnoteBackLabel: 'Kembali ke konten',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
await fixture.build();
|
|
|
|
const html = await fixture.readFile('/index.html');
|
|
|
|
const { document } = parseHTML(html);
|
|
|
|
|
2024-01-31 03:37:34 -05:00
|
|
|
assert.equal(document.querySelector('#footnote-label').textContent, 'Catatan kaki');
|
|
|
|
assert.equal(
|
|
|
|
document.querySelector('.data-footnote-backref').getAttribute('aria-label'),
|
2023-11-20 23:09:19 -05:00
|
|
|
'Back to reference 1'
|
2022-11-22 10:12:25 -05:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|