mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
30 lines
753 B
JavaScript
30 lines
753 B
JavaScript
import { createMarkdownProcessor } 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;
|
|
|
|
const processor = await createMarkdownProcessor({
|
|
remarkPlugins: [
|
|
function () {
|
|
const transformer = (tree, file) => {
|
|
context = file;
|
|
};
|
|
|
|
return transformer;
|
|
},
|
|
],
|
|
});
|
|
|
|
await processor.render(`test`, {
|
|
fileURL: new URL('virtual.md', import.meta.url),
|
|
});
|
|
|
|
chai.expect(typeof context).to.equal('object');
|
|
chai.expect(context.path).to.equal(fileURLToPath(new URL('virtual.md', import.meta.url)));
|
|
});
|
|
});
|