diff options
author | 2022-05-31 17:17:36 +0000 | |
---|---|---|
committer | 2022-05-31 17:17:36 +0000 | |
commit | 9a31e6f1d500219881ae1c79f4d6fef2809ef247 (patch) | |
tree | 7c77edde3bc7d8d0c6b931e7e969dce1b87cb8d4 | |
parent | 119ecf8d469f034eaf1b1217523954d29f492cb6 (diff) | |
download | astro-9a31e6f1d500219881ae1c79f4d6fef2809ef247.tar.gz astro-9a31e6f1d500219881ae1c79f4d6fef2809ef247.tar.zst astro-9a31e6f1d500219881ae1c79f4d6fef2809ef247.zip |
[ci] format
Diffstat (limited to '')
-rw-r--r-- | packages/astro/test/astro-markdown.test.js | 14 | ||||
-rw-r--r-- | packages/markdown/remark/src/rehype-jsx.ts | 5 | ||||
-rw-r--r-- | packages/markdown/remark/test/components.test.js | 10 |
3 files changed, 13 insertions, 16 deletions
diff --git a/packages/astro/test/astro-markdown.test.js b/packages/astro/test/astro-markdown.test.js index b001c6a83..1ef8a4b9a 100644 --- a/packages/astro/test/astro-markdown.test.js +++ b/packages/astro/test/astro-markdown.test.js @@ -291,23 +291,27 @@ describe('Astro Markdown', () => { expect(slots.find('> .fragmentSlot > div').text()).to.contain('1:'); expect(slots.find('> .fragmentSlot > div + p').text()).to.contain('2:'); expect(slots.find('> .pSlot > p[title="hello"]').text()).to.contain('3:'); - expect(slots.find('> .defaultSlot').text().replace(/\s+/g, ' ')).to.equal(` + expect(slots.find('> .defaultSlot').text().replace(/\s+/g, ' ')).to.equal( + ` 4: Div in default slot 5: Paragraph in fragment in default slot 6: Regular text in default slot - `.replace(/\s+/g, ' ')); + `.replace(/\s+/g, ' ') + ); const nestedSlots = $('article').eq(1); expect(nestedSlots.find('> .fragmentSlot').html()).to.contain('1:'); expect(nestedSlots.find('> .pSlot > p').text()).to.contain('2:'); - expect(nestedSlots.find('> .defaultSlot > article').text().replace(/\s+/g, ' ')).to.equal(` + expect(nestedSlots.find('> .defaultSlot > article').text().replace(/\s+/g, ' ')).to.equal( + ` 3: nested fragmentSlot 4: nested pSlot 5: nested text in default slot - `.replace(/\s+/g, ' ')); + `.replace(/\s+/g, ' ') + ); expect($('article').eq(3).text().replace(/[^❌]/g, '')).to.equal('❌❌❌'); - + expect($('article').eq(4).text().replace(/[^❌]/g, '')).to.equal('❌❌❌'); }); }); diff --git a/packages/markdown/remark/src/rehype-jsx.ts b/packages/markdown/remark/src/rehype-jsx.ts index 46c200b70..daeb4d56a 100644 --- a/packages/markdown/remark/src/rehype-jsx.ts +++ b/packages/markdown/remark/src/rehype-jsx.ts @@ -7,9 +7,8 @@ export default function rehypeJsx(): any { child.tagName = `${child.tagName}`; }); visit(node, MDX_ELEMENTS, (child: any, index: number | null, parent: any) => { - if (index === null || !Boolean(parent)) - return; - + if (index === null || !Boolean(parent)) return; + const attrs = child.attributes.reduce((acc: any[], entry: any) => { let attr = entry.value; if (attr && typeof attr === 'object') { diff --git a/packages/markdown/remark/test/components.test.js b/packages/markdown/remark/test/components.test.js index 59816b76e..ca0a3fdb4 100644 --- a/packages/markdown/remark/test/components.test.js +++ b/packages/markdown/remark/test/components.test.js @@ -49,9 +49,7 @@ describe('components', () => { it('should normalize children', async () => { const { code } = await renderMarkdown(`<Component bool={true}>Hello world!</Component>`, {}); - chai - .expect(code) - .to.equal(`\n<Component bool={true}>Hello world!</Component>\n`); + chai.expect(code).to.equal(`\n<Component bool={true}>Hello world!</Component>\n`); }); it('should be able to nest components', async () => { @@ -73,10 +71,6 @@ describe('components', () => { {} ); - chai - .expect(code) - .to.equal( - `\n<Component><h1 id="hello-world">Hello world!</h1></Component>\n` - ); + chai.expect(code).to.equal(`\n<Component><h1 id="hello-world">Hello world!</h1></Component>\n`); }); }); |