0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00
astro/packages/markdown/remark/test/plugins.test.js
Emanuele Stoppa 062623438b
chore: use biome to sort imports - only test files (#10180)
* chore: use biome to sort imports

* do the sorting

* Update package.json

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>

---------

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
2024-02-21 14:08:19 +00:00

28 lines
736 B
JavaScript

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)));
});
});