2022-05-24 17:02:11 -05:00
|
|
|
import { renderMarkdown } from '../dist/index.js';
|
2023-01-11 12:51:31 -05:00
|
|
|
import { mockRenderMarkdownParams } from './test-utils.js';
|
2022-05-24 17:02:11 -05:00
|
|
|
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`, {
|
2023-01-11 12:51:31 -05:00
|
|
|
...mockRenderMarkdownParams,
|
2022-05-24 17:02:11 -05:00
|
|
|
fileURL: new URL('virtual.md', import.meta.url),
|
|
|
|
remarkPlugins: [
|
|
|
|
function () {
|
|
|
|
const transformer = (tree, file) => {
|
|
|
|
context = file;
|
|
|
|
};
|
|
|
|
|
|
|
|
return transformer;
|
2022-05-24 17:03:29 -05:00
|
|
|
},
|
|
|
|
],
|
2022-05-24 17:02:11 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
chai.expect(typeof context).to.equal('object');
|
|
|
|
chai.expect(context.path).to.equal(fileURLToPath(new URL('virtual.md', import.meta.url)));
|
|
|
|
});
|
2022-05-24 17:03:29 -05:00
|
|
|
});
|