summaryrefslogtreecommitdiff
path: root/packages/markdown/remark/test/plugins.test.js
blob: a1abeb2ed242874acebc070d71a753915b093918 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { renderMarkdown } 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;
		await renderMarkdown(`test`, {
			fileURL: new URL('virtual.md', import.meta.url),
			remarkPlugins: [
				function () {
					const transformer = (tree, file) => {
						context = file;
					};

					return transformer;
				},
			],
		});

		chai.expect(typeof context).to.equal('object');
		chai.expect(context.path).to.equal(fileURLToPath(new URL('virtual.md', import.meta.url)));
	});
});