diff options
Diffstat (limited to 'packages/markdown/remark/test/plugins.test.js')
-rw-r--r-- | packages/markdown/remark/test/plugins.test.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/markdown/remark/test/plugins.test.js b/packages/markdown/remark/test/plugins.test.js new file mode 100644 index 000000000..4954047b5 --- /dev/null +++ b/packages/markdown/remark/test/plugins.test.js @@ -0,0 +1,26 @@ +import { renderMarkdown } from '../dist/index.js'; +import chai from 'chai'; + +import { fileURLToPath } from 'node:url'; + +describe('plugins', () => { + // https://github.com/withastro/astro/issues/3264 + it('should be able to get file path when passing fileURL', async () => { + let context; + await renderMarkdown(`test`, { + fileURL: new URL('virtual.md', import.meta.url), + remarkPlugins: [ + function () { + const transformer = (tree, file) => { + context = file; + }; + + return transformer; + } + ] + }); + + chai.expect(typeof context).to.equal('object'); + chai.expect(context.path).to.equal(fileURLToPath(new URL('virtual.md', import.meta.url))); + }); +}) |