From 87504fb95eda1e0aad84b117ee9a7c5054de18e2 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Thu, 19 May 2022 15:55:03 -0500 Subject: [PATCH] fix(#2474): ensure namespaced components are properly handled in markdown pages --- packages/astro/test/astro-markdown.test.js | 8 ++++++++ .../test/fixtures/astro-markdown/src/components/index.js | 5 +++++ .../test/fixtures/astro-markdown/src/pages/namespace.md | 7 +++++++ 3 files changed, 20 insertions(+) create mode 100644 packages/astro/test/fixtures/astro-markdown/src/components/index.js create mode 100644 packages/astro/test/fixtures/astro-markdown/src/pages/namespace.md diff --git a/packages/astro/test/astro-markdown.test.js b/packages/astro/test/astro-markdown.test.js index 2836ba0acd66f..6270c85895ace 100644 --- a/packages/astro/test/astro-markdown.test.js +++ b/packages/astro/test/astro-markdown.test.js @@ -42,6 +42,14 @@ describe('Astro Markdown', () => { expect($('h1').attr("id")).to.equal('my-blog-post'); }); + it('Can handle namespaced components in markdown', async () => { + const html = await fixture.readFile('/namespace/index.html'); + const $ = cheerio.load(html); + + expect($('h1').text()).to.equal('Hello Namespace!'); + expect($('button').length).to.equal(1); + }); + it('Correctly handles component children in markdown pages (#3319)', async () => { const html = await fixture.readFile('/children/index.html'); diff --git a/packages/astro/test/fixtures/astro-markdown/src/components/index.js b/packages/astro/test/fixtures/astro-markdown/src/components/index.js new file mode 100644 index 0000000000000..e7cc94c588f25 --- /dev/null +++ b/packages/astro/test/fixtures/astro-markdown/src/components/index.js @@ -0,0 +1,5 @@ +import Counter from './Counter'; + +export default { + Counter +} diff --git a/packages/astro/test/fixtures/astro-markdown/src/pages/namespace.md b/packages/astro/test/fixtures/astro-markdown/src/pages/namespace.md new file mode 100644 index 0000000000000..abbe26a3b0275 --- /dev/null +++ b/packages/astro/test/fixtures/astro-markdown/src/pages/namespace.md @@ -0,0 +1,7 @@ +--- +setup: import ns from '../components/index.js'; +--- + +# Hello Namespace! + +Click me!