Add tests for assets using imports (#2090)

This commit is contained in:
Matthew Phillips 2021-12-02 12:32:42 -05:00 committed by GitHub
parent ac3e870280
commit 97174e6ff4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 0 deletions

View file

@ -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);
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 KiB

View file

@ -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>