mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
import { createMarkdownProcessor } from '../dist/index.js';
|
|
import chai from 'chai';
|
|
|
|
describe('collect images', async () => {
|
|
const processor = await createMarkdownProcessor();
|
|
|
|
it('should collect inline image paths', async () => {
|
|
const {
|
|
code,
|
|
metadata: { imagePaths },
|
|
} = await processor.render(`Hello ![inline image url](./img.png)`, {
|
|
fileURL: 'file.md',
|
|
});
|
|
|
|
chai
|
|
.expect(code)
|
|
.to.equal(
|
|
'<p>Hello <img __ASTRO_IMAGE_="{"src":"./img.png","alt":"inline image url","index":0}"></p>'
|
|
);
|
|
|
|
chai.expect(Array.from(imagePaths)).to.deep.equal(['./img.png']);
|
|
});
|
|
|
|
it('should add image paths from definition', async () => {
|
|
const {
|
|
code,
|
|
metadata: { imagePaths },
|
|
} = await processor.render(`Hello ![image ref][img-ref]\n\n[img-ref]: ./img.webp`, {
|
|
fileURL: 'file.md',
|
|
});
|
|
|
|
chai
|
|
.expect(code)
|
|
.to.equal(
|
|
'<p>Hello <img __ASTRO_IMAGE_="{"src":"./img.webp","alt":"image ref","index":0}"></p>'
|
|
);
|
|
chai.expect(Array.from(imagePaths)).to.deep.equal(['./img.webp']);
|
|
});
|
|
});
|