mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
165cfc154b
* pass hProperties to getImage for optimized imgs * fix to allow multiple images to have hProps added * update test to reflect new expected result * add comment back in Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> * add srcset * works on multiple images * fix tests, fix images.ts type and remove console logs * add warning back to images.ts again lol * update changeset to be user oriented * Update calm-socks-shake.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * pass alt through getImage * added fixture and test * update lockfile * fix lockfile again (had installed an extra package during testing and had sharp33 installed) * update test to reflect passing alt through getImage --------- Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
33 lines
1.2 KiB
JavaScript
33 lines
1.2 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']);
|
|
});
|
|
});
|