diff options
author | 2022-05-27 16:56:08 -0400 | |
---|---|---|
committer | 2022-05-27 16:56:08 -0400 | |
commit | 47d1a8d59cb3d88655de3d7658026e84843cb043 (patch) | |
tree | 2f227f1559161463a1d0ad13dd2c2ad2f2d12485 /packages/astro/test/astro-markdown.test.js | |
parent | ffe5cf031239e177a18f20cdfceb07854a758463 (diff) | |
download | astro-47d1a8d59cb3d88655de3d7658026e84843cb043.tar.gz astro-47d1a8d59cb3d88655de3d7658026e84843cb043.tar.zst astro-47d1a8d59cb3d88655de3d7658026e84843cb043.zip |
Feat: markdown `content.raw()` and `content.compiled()` helpers (#3452)
* feat: add rawContent obj with html helper
* refactor: change toString to function call
* test: rawContent helpers
* chore: update MarkdownInstance type
* refactor: parseHtml -> html
* chore: changeset
* fix: remove needless async heading on content version
* fix: fixLineEndings helper on unit tests
* refactor: change api to raw and compiled
* chore: add new type to env.d.ts
* docs: JSdocs for raw and compiled
* refactor: change API AGAIN to rawContent, compiledContent
* chore: update changeset
Diffstat (limited to '')
-rw-r--r-- | packages/astro/test/astro-markdown.test.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/packages/astro/test/astro-markdown.test.js b/packages/astro/test/astro-markdown.test.js index 525522316..d98dabe18 100644 --- a/packages/astro/test/astro-markdown.test.js +++ b/packages/astro/test/astro-markdown.test.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { loadFixture, fixLineEndings } from './test-utils.js'; describe('Astro Markdown', () => { let fixture; @@ -233,4 +233,16 @@ describe('Astro Markdown', () => { expect($('#target > ol > li').children()).to.have.lengthOf(1); expect($('#target > ol > li > ol > li').text()).to.equal('nested hello'); }); + + it('Exposes raw markdown content', async () => { + const { raw } = JSON.parse(await fixture.readFile('/raw-content.json')); + + expect(fixLineEndings(raw)).to.equal(`\n## With components\n\n### Non-hydrated\n\n<Hello name="Astro Naut" />\n\n### Hydrated\n\n<Counter client:load />\n<SvelteButton client:load />\n`); + }); + + it('Exposes HTML parser for raw markdown content', async () => { + const { compiled } = JSON.parse(await fixture.readFile('/raw-content.json')); + + expect(fixLineEndings(compiled)).to.equal(`<h2 id="with-components">With components</h2>\n<h3 id="non-hydrated">Non-hydrated</h3>\n<Hello name="Astro Naut" />\n<h3 id="hydrated">Hydrated</h3>\n<Counter client:load />\n<SvelteButton client:load />`); + }) }); |