Add tests for assets using imports (#2090)
This commit is contained in:
parent
ac3e870280
commit
97174e6ff4
4 changed files with 23 additions and 0 deletions
|
@ -42,4 +42,20 @@ describe('Assets', () => {
|
|||
const data = await fixture.readFile('/' + match.url);
|
||||
expect(!!data).to.equal(true);
|
||||
});
|
||||
|
||||
it('built image from an import specifier', async () => {
|
||||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
const src = '/' + $('#import-no-url').attr('src');
|
||||
const data = await fixture.readFile(src);
|
||||
expect(!!data).to.equal(true);
|
||||
});
|
||||
|
||||
it('built image from an import specifier using ?url', async () => {
|
||||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
const src = '/' + $('#import-url').attr('src');
|
||||
const data = await fixture.readFile(src);
|
||||
expect(!!data).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
|
BIN
packages/astro/test/fixtures/astro-assets/src/images/penguin1.jpg
vendored
Normal file
BIN
packages/astro/test/fixtures/astro-assets/src/images/penguin1.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
packages/astro/test/fixtures/astro-assets/src/images/penguin2.jpg
vendored
Normal file
BIN
packages/astro/test/fixtures/astro-assets/src/images/penguin2.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 299 KiB |
|
@ -1,3 +1,7 @@
|
|||
---
|
||||
import p1Url from '../images/penguin1.jpg';
|
||||
import p2Url from '../images/penguin2.jpg?url';
|
||||
---
|
||||
<html lang="en">
|
||||
<head><title>This Site</title></head>
|
||||
<style>
|
||||
|
@ -15,5 +19,8 @@
|
|||
<picture>
|
||||
<source srcset="https://ik.imagekit.io/demo/tr:w-300,h-300/medium_cafe_B1iTdD0C.jpg, https://ik.imagekit.io/demo/tr:w-450,h-450/medium_cafe_B1iTdD0C.jpg 600w, https://ik.imagekit.io/demo/tr:w-600,h-600/medium_cafe_B1iTdD0C.jpg 800w">
|
||||
</picture>
|
||||
|
||||
<img src={p1Url} id="import-no-url" />
|
||||
<img src={p2Url} id="import-url" />
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue