diff options
author | 2022-08-01 21:25:50 +0000 | |
---|---|---|
committer | 2022-08-01 21:25:50 +0000 | |
commit | 10a8fa5dcd958605deb41f0f5fe8b2f2ee7229b5 (patch) | |
tree | 32b629acb81c0807b908a139118b572ea367ca7f /packages/integrations/mdx/test/mdx-get-headings.test.js | |
parent | 40ef43a59b08a1a8fbcd9f4a53745a9636a4fbb9 (diff) | |
download | astro-10a8fa5dcd958605deb41f0f5fe8b2f2ee7229b5.tar.gz astro-10a8fa5dcd958605deb41f0f5fe8b2f2ee7229b5.tar.zst astro-10a8fa5dcd958605deb41f0f5fe8b2f2ee7229b5.zip |
[ci] format
Diffstat (limited to 'packages/integrations/mdx/test/mdx-get-headings.test.js')
-rw-r--r-- | packages/integrations/mdx/test/mdx-get-headings.test.js | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/packages/integrations/mdx/test/mdx-get-headings.test.js b/packages/integrations/mdx/test/mdx-get-headings.test.js index 247ffedb4..1ac7283dd 100644 --- a/packages/integrations/mdx/test/mdx-get-headings.test.js +++ b/packages/integrations/mdx/test/mdx-get-headings.test.js @@ -20,8 +20,8 @@ describe('MDX getHeadings', () => { const html = await fixture.readFile('/test/index.html'); const { document } = parseHTML(html); - const h2Ids = document.querySelectorAll('h2').map(el => el?.id); - const h3Ids = document.querySelectorAll('h3').map(el => el?.id); + const h2Ids = document.querySelectorAll('h2').map((el) => el?.id); + const h3Ids = document.querySelectorAll('h3').map((el) => el?.id); expect(document.querySelector('h1').id).to.equal('heading-test'); expect(h2Ids).to.contain('section-1'); expect(h2Ids).to.contain('section-2'); @@ -32,25 +32,29 @@ describe('MDX getHeadings', () => { it('generates correct getHeadings() export', async () => { const { headingsByPage } = JSON.parse(await fixture.readFile('/pages.json')); // TODO: make this a snapshot test :) - expect(JSON.stringify(headingsByPage['./test.mdx'])).to.equal(JSON.stringify([ - { depth: 1, slug: 'heading-test', text: 'Heading test' }, - { depth: 2, slug: 'section-1', text: 'Section 1' }, - { depth: 3, slug: 'subsection-1', text: 'Subsection 1' }, - { depth: 3, slug: 'subsection-2', text: 'Subsection 2' }, - { depth: 2, slug: 'section-2', text: 'Section 2' } - ])); + expect(JSON.stringify(headingsByPage['./test.mdx'])).to.equal( + JSON.stringify([ + { depth: 1, slug: 'heading-test', text: 'Heading test' }, + { depth: 2, slug: 'section-1', text: 'Section 1' }, + { depth: 3, slug: 'subsection-1', text: 'Subsection 1' }, + { depth: 3, slug: 'subsection-2', text: 'Subsection 2' }, + { depth: 2, slug: 'section-2', text: 'Section 2' }, + ]) + ); }); - + it('generates correct getHeadings() export for JSX expressions', async () => { const { headingsByPage } = JSON.parse(await fixture.readFile('/pages.json')); - expect(JSON.stringify(headingsByPage['./test-with-jsx-expressions.mdx'])).to.equal(JSON.stringify([ - { - depth: 1, - slug: 'heading-test-with-jsx-expressions', - text: 'Heading test with JSX expressions' - }, - { depth: 2, slug: 'h2title', text: 'h2Title' }, - { depth: 3, slug: 'h3title', text: 'h3Title' } - ])); + expect(JSON.stringify(headingsByPage['./test-with-jsx-expressions.mdx'])).to.equal( + JSON.stringify([ + { + depth: 1, + slug: 'heading-test-with-jsx-expressions', + text: 'Heading test with JSX expressions', + }, + { depth: 2, slug: 'h2title', text: 'h2Title' }, + { depth: 3, slug: 'h3title', text: 'h3Title' }, + ]) + ); }); }); |