0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/markdown/remark/test/plugins.test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
736 B
JavaScript
Raw Normal View History

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;
2022-05-24 17:03:29 -05:00
},
],
});
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)));
});
2022-05-24 17:03:29 -05:00
});