summaryrefslogtreecommitdiff
path: root/packages/integrations/image/test/image-ssr.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/image/test/image-ssr.test.js')
-rw-r--r--packages/integrations/image/test/image-ssr.test.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/packages/integrations/image/test/image-ssr.test.js b/packages/integrations/image/test/image-ssr.test.js
index 9881d090a..784a92e53 100644
--- a/packages/integrations/image/test/image-ssr.test.js
+++ b/packages/integrations/image/test/image-ssr.test.js
@@ -62,6 +62,32 @@ describe('SSR images - build', function () {
});
});
+ describe('Inline imports', () => {
+ it('includes src, width, and height attributes', async () => {
+ const app = await fixture.loadTestAdapterApp();
+
+ const request = new Request('http://example.com/');
+ const response = await app.render(request);
+ const html = await response.text();
+ const $ = cheerio.load(html);
+
+ const image = $('#inline');
+
+ const src = image.attr('src');
+ const [route, params] = src.split('?');
+
+ expect(route).to.equal('/_image');
+
+ const searchParams = new URLSearchParams(params);
+
+ expect(searchParams.get('f')).to.equal('jpg');
+ expect(searchParams.get('w')).to.equal('506');
+ expect(searchParams.get('h')).to.equal('253');
+ // TODO: possible to avoid encoding the full image path?
+ expect(searchParams.get('href').endsWith('/assets/social.jpg')).to.equal(true);
+ });
+ });
+
describe('Remote images', () => {
it('includes src, width, and height attributes', async () => {
const app = await fixture.loadTestAdapterApp();
@@ -142,6 +168,25 @@ describe('SSR images - dev', function () {
});
});
+ describe('Inline imports', () => {
+ it('includes src, width, and height attributes', () => {
+ const image = $('#inline');
+
+ const src = image.attr('src');
+ const [route, params] = src.split('?');
+
+ expect(route).to.equal('/_image');
+
+ const searchParams = new URLSearchParams(params);
+
+ expect(searchParams.get('f')).to.equal('jpg');
+ expect(searchParams.get('w')).to.equal('506');
+ expect(searchParams.get('h')).to.equal('253');
+ // TODO: possible to avoid encoding the full image path?
+ expect(searchParams.get('href').endsWith('/assets/social.jpg')).to.equal(true);
+ });
+ });
+
describe('Remote images', () => {
it('includes src, width, and height attributes', () => {
const image = $('#google');