Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Aug 14, 2023
1 parent de047ad commit 086c167
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/astro/src/assets/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export type LocalImageProps<T> = ImageSharedProps<T> & {
* <Image src={myImage} alt="..."></Image>
* ```
*/
src: ImageMetadata;
src: ImageMetadata | Promise<{ default: ImageMetadata }>;
/**
* Desired output format for the image. Defaults to `webp`.
*
Expand Down
13 changes: 13 additions & 0 deletions packages/astro/test/core-image.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,19 @@ describe('astro:image', () => {
})
).to.be.true;
});

it('supports inlined imports', async () => {
let res = await fixture.fetch('/inlineImport');
let html = await res.text();
$ = cheerio.load(html);

let $img = $('img');
expect($img).to.have.a.lengthOf(1);

let src = $img.attr('src');
res = await fixture.fetch(src);
expect(res.status).to.equal(200);
});
});

describe('vite-isms', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
import { getImage } from "astro:assets";
const optimizedImage = await getImage({src: import('../assets/penguin1.jpg')})
---

<img src={optimizedImage.src} {...optimizedImage.attributes} />

0 comments on commit 086c167

Please sign in to comment.