diff options
Diffstat (limited to 'packages/markdown/remark/test/plugins.test.js')
-rw-r--r-- | packages/markdown/remark/test/plugins.test.js | 28 |
1 files changed, 28 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..c52955f83 --- /dev/null +++ b/packages/markdown/remark/test/plugins.test.js @@ -0,0 +1,28 @@ +import assert from 'node:assert/strict'; +import { describe, it } from 'node:test'; +import { fileURLToPath } from 'node:url'; +import { createMarkdownProcessor } from '../dist/index.js'; + +describe('plugins', () => { + it('should be able to get file path when passing fileURL', async () => { + let context; + + const processor = await createMarkdownProcessor({ + remarkPlugins: [ + () => { + const transformer = (_tree, file) => { + context = file; + }; + return transformer; + }, + ], + }); + + await processor.render(`test`, { + fileURL: new URL('virtual.md', import.meta.url), + }); + + assert.ok(typeof context === 'object'); + assert.equal(context.path, fileURLToPath(new URL('virtual.md', import.meta.url))); + }); +}); |