0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00
astro/packages/markdown/remark/test/plugins.test.js
Shoaib Khan 2dbb6a3e08
chore: Migrate All packages/markdown/remark/tests to node:test (#10083)
* chore: Migrate All packages/markdown/remark/tests to node:test

* Some minor fixes
2024-02-12 12:25:29 +00:00

28 lines
736 B
JavaScript

import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { createMarkdownProcessor } from '../dist/index.js';
import { fileURLToPath } from 'node:url';
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)));
});
});