summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/test/mdx-plugins.test.js
diff options
context:
space:
mode:
authorGravatar Ben Holmes <hey@bholmes.dev> 2023-01-06 09:26:02 -0500
committerGravatar GitHub <noreply@github.com> 2023-01-06 09:26:02 -0500
commit93e633922c2e449df3bb2357b3683af1d3c0e07b (patch)
tree5a81cd3e18653bef795a9bb8c8e993416fb48e42 /packages/integrations/mdx/test/mdx-plugins.test.js
parent04bf679a5d509197aa3b7587e511588f652e886e (diff)
downloadastro-93e633922c2e449df3bb2357b3683af1d3c0e07b.tar.gz
astro-93e633922c2e449df3bb2357b3683af1d3c0e07b.tar.zst
astro-93e633922c2e449df3bb2357b3683af1d3c0e07b.zip
Add SmartyPants flag (#5769)
* feat: add smartypants flag * test: smartypants in markdown and mdx * docs: Smartypants -> SmartyPants * chore: changeset * chore: update changeset with 1.0 -> 2.0 in mind * chore: bump to minor change
Diffstat (limited to 'packages/integrations/mdx/test/mdx-plugins.test.js')
-rw-r--r--packages/integrations/mdx/test/mdx-plugins.test.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/integrations/mdx/test/mdx-plugins.test.js b/packages/integrations/mdx/test/mdx-plugins.test.js
index f74ded3ea..828bcb3d5 100644
--- a/packages/integrations/mdx/test/mdx-plugins.test.js
+++ b/packages/integrations/mdx/test/mdx-plugins.test.js
@@ -36,6 +36,19 @@ describe('MDX plugins', () => {
expect(selectGfmLink(document)).to.not.be.null;
});
+ it('Applies SmartyPants by default', async () => {
+ const fixture = await buildFixture({
+ integrations: [mdx()],
+ });
+
+ const html = await fixture.readFile(FILE);
+ const { document } = parseHTML(html);
+
+ const quote = selectSmartypantsQuote(document);
+ expect(quote).to.not.be.null;
+ expect(quote.textContent).to.contain('“Smartypants” is — awesome');
+ });
+
it('supports custom rehype plugins', async () => {
const fixture = await buildFixture({
integrations: [
@@ -88,6 +101,7 @@ describe('MDX plugins', () => {
markdown: {
remarkPlugins: [remarkToc],
gfm: false,
+ smartypants: false,
},
integrations: [
mdx({
@@ -129,6 +143,23 @@ describe('MDX plugins', () => {
expect(selectGfmLink(document), 'Respects `markdown.gfm` unexpectedly.').to.not.be.null;
}
});
+
+ it('Handles smartypants', async () => {
+ const html = await fixture.readFile(FILE);
+ const { document } = parseHTML(html);
+
+ const quote = selectSmartypantsQuote(document);
+
+ if (extendMarkdownConfig === true) {
+ expect(quote.textContent, 'Does not respect `markdown.smartypants` option.').to.contain(
+ '"Smartypants" is -- awesome'
+ );
+ } else {
+ expect(quote.textContent, 'Respects `markdown.smartypants` unexpectedly.').to.contain(
+ '“Smartypants” is — awesome'
+ );
+ }
+ });
});
}
@@ -202,6 +233,10 @@ function selectGfmLink(document) {
return document.querySelector('a[href="https://handle-me-gfm.com"]');
}
+function selectSmartypantsQuote(document) {
+ return document.querySelector('blockquote');
+}
+
function selectRemarkExample(document) {
return document.querySelector('div[data-remark-plugin-works]');
}