2022-07-01 15:47:48 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import * as cheerio from 'cheerio';
|
|
|
|
import sizeOf from 'image-size';
|
2023-07-18 00:17:59 +00:00
|
|
|
import fs from 'node:fs/promises';
|
2023-01-30 20:29:41 +00:00
|
|
|
import { join } from 'node:path';
|
2023-07-18 00:17:59 +00:00
|
|
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
2022-07-01 15:47:48 +00:00
|
|
|
import { loadFixture } from './test-utils.js';
|
|
|
|
|
2023-01-30 20:29:41 +00:00
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
2023-01-30 20:31:49 +00:00
|
|
|
const toAstroImage = (relpath) =>
|
|
|
|
'/@astroimage' + pathToFileURL(join(__dirname, 'fixtures/basic-image', relpath)).pathname;
|
2023-01-30 20:29:41 +00:00
|
|
|
|
2022-08-30 21:09:44 +00:00
|
|
|
describe('SSG images - dev', function () {
|
|
|
|
let fixture;
|
|
|
|
let devServer;
|
|
|
|
let $;
|
2022-08-30 21:12:45 +00:00
|
|
|
|
2022-07-01 15:47:48 +00:00
|
|
|
before(async () => {
|
|
|
|
fixture = await loadFixture({ root: './fixtures/basic-image/' });
|
2022-08-30 21:09:44 +00:00
|
|
|
devServer = await fixture.startDevServer();
|
2022-08-30 21:12:45 +00:00
|
|
|
const html = await fixture.fetch('/').then((res) => res.text());
|
|
|
|
$ = cheerio.load(html);
|
2022-07-01 15:47:48 +00:00
|
|
|
});
|
|
|
|
|
2022-08-30 21:09:44 +00:00
|
|
|
after(async () => {
|
|
|
|
await devServer.stop();
|
|
|
|
});
|
2022-07-01 15:47:48 +00:00
|
|
|
|
2022-09-01 14:58:57 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
title: 'Local images',
|
|
|
|
id: '#social-jpg',
|
2023-01-30 20:29:41 +00:00
|
|
|
url: toAstroImage('src/assets/social.jpg'),
|
2022-09-01 15:01:07 +00:00
|
|
|
query: { f: 'jpg', w: '506', h: '253' },
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
2022-09-30 17:27:56 +00:00
|
|
|
{
|
|
|
|
title: 'Local image no transforms',
|
|
|
|
id: '#no-transforms',
|
2023-01-30 20:29:41 +00:00
|
|
|
url: toAstroImage('src/assets/social.jpg'),
|
2022-09-30 17:29:32 +00:00
|
|
|
query: {},
|
2022-09-30 17:27:56 +00:00
|
|
|
},
|
2022-09-01 20:31:53 +00:00
|
|
|
{
|
|
|
|
title: 'Filename with spaces',
|
|
|
|
id: '#spaces',
|
2023-01-30 20:29:41 +00:00
|
|
|
url: toAstroImage('src/assets/blog/introducing astro.jpg'),
|
2022-09-01 20:31:53 +00:00
|
|
|
query: { f: 'webp', w: '768', h: '414' },
|
|
|
|
},
|
2023-01-30 20:29:41 +00:00
|
|
|
{
|
|
|
|
title: 'File outside src',
|
|
|
|
id: '#outside-src',
|
|
|
|
url: toAstroImage('social.png'),
|
|
|
|
query: { f: 'png', w: '2024', h: '1012' },
|
|
|
|
contentType: 'image/png',
|
|
|
|
},
|
2023-02-15 08:21:41 +00:00
|
|
|
{
|
|
|
|
title: 'SVG image',
|
|
|
|
id: '#logo-svg',
|
|
|
|
url: toAstroImage('src/assets/logo.svg'),
|
|
|
|
query: { f: 'svg', w: '192', h: '256' },
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
{
|
|
|
|
title: 'Inline imports',
|
|
|
|
id: '#inline',
|
2023-01-30 20:29:41 +00:00
|
|
|
url: toAstroImage('src/assets/social.jpg'),
|
2022-09-01 15:01:07 +00:00
|
|
|
query: { f: 'jpg', w: '506', h: '253' },
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Remote images',
|
|
|
|
id: '#google',
|
|
|
|
url: '/_image',
|
|
|
|
query: {
|
|
|
|
f: 'webp',
|
|
|
|
w: '544',
|
|
|
|
h: '184',
|
2022-09-01 15:01:07 +00:00
|
|
|
href: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png',
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
2022-09-07 13:56:07 +00:00
|
|
|
{
|
|
|
|
title: 'Remote without file extension',
|
|
|
|
id: '#ipsum',
|
|
|
|
url: '/_image',
|
|
|
|
query: {
|
|
|
|
w: '200',
|
|
|
|
h: '300',
|
2022-09-22 19:48:14 +00:00
|
|
|
href: 'https://dummyimage.com/200x300',
|
2022-09-07 13:57:52 +00:00
|
|
|
},
|
2022-09-07 13:56:07 +00:00
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
{
|
|
|
|
title: 'Public images',
|
|
|
|
id: '#hero',
|
|
|
|
url: '/_image',
|
2022-09-01 15:01:07 +00:00
|
|
|
query: { f: 'webp', w: '768', h: '414', href: '/hero.jpg' },
|
|
|
|
},
|
2022-09-07 17:22:11 +00:00
|
|
|
{
|
|
|
|
title: 'Background color',
|
|
|
|
id: '#bg-color',
|
|
|
|
url: '/_image',
|
|
|
|
query: {
|
|
|
|
f: 'jpeg',
|
|
|
|
w: '544',
|
|
|
|
h: '184',
|
|
|
|
bg: '#333333',
|
|
|
|
href: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png',
|
|
|
|
},
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
].forEach(({ title, id, url, query }) => {
|
|
|
|
it(title, () => {
|
|
|
|
const image = $(id);
|
2022-07-01 15:47:48 +00:00
|
|
|
|
2022-08-30 21:09:44 +00:00
|
|
|
const src = image.attr('src');
|
|
|
|
const [route, params] = src.split('?');
|
2022-07-01 15:47:48 +00:00
|
|
|
|
2022-09-01 14:58:57 +00:00
|
|
|
expect(route).to.equal(url);
|
2022-07-01 15:47:48 +00:00
|
|
|
|
2022-08-30 21:09:44 +00:00
|
|
|
const searchParams = new URLSearchParams(params);
|
2022-07-01 15:47:48 +00:00
|
|
|
|
2022-09-01 14:58:57 +00:00
|
|
|
for (const [key, value] of Object.entries(query)) {
|
|
|
|
expect(searchParams.get(key)).to.equal(value);
|
|
|
|
}
|
2022-08-30 21:09:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('SSG images with subpath - dev', function () {
|
|
|
|
let fixture;
|
|
|
|
let devServer;
|
|
|
|
let $;
|
2022-08-30 21:12:45 +00:00
|
|
|
|
2022-08-30 21:09:44 +00:00
|
|
|
before(async () => {
|
|
|
|
fixture = await loadFixture({ root: './fixtures/basic-image/', base: '/docs' });
|
|
|
|
devServer = await fixture.startDevServer();
|
2022-08-30 21:12:45 +00:00
|
|
|
const html = await fixture.fetch('/docs/').then((res) => res.text());
|
|
|
|
$ = cheerio.load(html);
|
2022-08-30 21:09:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
after(async () => {
|
|
|
|
await devServer.stop();
|
|
|
|
});
|
|
|
|
|
2022-09-01 14:58:57 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
title: 'Local images',
|
|
|
|
id: '#social-jpg',
|
2023-01-30 20:29:41 +00:00
|
|
|
url: toAstroImage('src/assets/social.jpg'),
|
2022-09-01 15:01:07 +00:00
|
|
|
query: { f: 'jpg', w: '506', h: '253' },
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
2023-01-30 20:29:41 +00:00
|
|
|
{
|
|
|
|
title: 'Local image no transforms',
|
|
|
|
id: '#no-transforms',
|
|
|
|
url: toAstroImage('src/assets/social.jpg'),
|
|
|
|
query: {},
|
|
|
|
},
|
2022-09-01 20:31:53 +00:00
|
|
|
{
|
|
|
|
title: 'Filename with spaces',
|
|
|
|
id: '#spaces',
|
2023-01-30 20:29:41 +00:00
|
|
|
url: toAstroImage('src/assets/blog/introducing astro.jpg'),
|
2022-09-01 20:31:53 +00:00
|
|
|
query: { f: 'webp', w: '768', h: '414' },
|
|
|
|
},
|
2023-01-30 20:29:41 +00:00
|
|
|
{
|
|
|
|
title: 'File outside src',
|
|
|
|
id: '#outside-src',
|
|
|
|
url: toAstroImage('social.png'),
|
|
|
|
query: { f: 'png', w: '2024', h: '1012' },
|
|
|
|
contentType: 'image/png',
|
|
|
|
},
|
2023-02-15 08:21:41 +00:00
|
|
|
{
|
|
|
|
title: 'SVG image',
|
|
|
|
id: '#logo-svg',
|
|
|
|
url: toAstroImage('src/assets/logo.svg'),
|
|
|
|
query: { f: 'svg', w: '192', h: '256' },
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
{
|
|
|
|
title: 'Inline imports',
|
|
|
|
id: '#inline',
|
2023-01-30 20:29:41 +00:00
|
|
|
url: toAstroImage('src/assets/social.jpg'),
|
2022-09-01 15:01:07 +00:00
|
|
|
query: { f: 'jpg', w: '506', h: '253' },
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Remote images',
|
|
|
|
id: '#google',
|
|
|
|
url: '/_image',
|
|
|
|
query: {
|
|
|
|
f: 'webp',
|
|
|
|
w: '544',
|
|
|
|
h: '184',
|
2022-09-01 15:01:07 +00:00
|
|
|
href: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png',
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
2022-09-07 13:56:07 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
title: 'Remote without file extension',
|
|
|
|
id: '#ipsum',
|
|
|
|
url: '/_image',
|
|
|
|
query: {
|
|
|
|
w: '200',
|
|
|
|
h: '300',
|
2022-09-22 19:48:14 +00:00
|
|
|
href: 'https://dummyimage.com/200x300',
|
2022-09-07 13:57:52 +00:00
|
|
|
},
|
2022-09-07 13:56:07 +00:00
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
{
|
|
|
|
title: 'Public images',
|
|
|
|
id: '#hero',
|
|
|
|
url: '/_image',
|
2022-11-09 15:22:53 +00:00
|
|
|
query: { f: 'webp', w: '768', h: '414', href: '/docs/hero.jpg' },
|
2022-09-01 15:01:07 +00:00
|
|
|
},
|
2022-09-07 17:22:11 +00:00
|
|
|
{
|
|
|
|
title: 'Background color',
|
|
|
|
id: '#bg-color',
|
|
|
|
url: '/_image',
|
|
|
|
query: {
|
|
|
|
f: 'jpeg',
|
|
|
|
w: '544',
|
|
|
|
h: '184',
|
|
|
|
bg: '#333333',
|
|
|
|
href: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png',
|
|
|
|
},
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
].forEach(({ title, id, url, query }) => {
|
|
|
|
it(title, () => {
|
|
|
|
const image = $(id);
|
2022-07-01 15:47:48 +00:00
|
|
|
|
2022-08-30 21:09:44 +00:00
|
|
|
const src = image.attr('src');
|
|
|
|
const [route, params] = src.split('?');
|
2022-07-01 15:47:48 +00:00
|
|
|
|
2022-09-01 14:58:57 +00:00
|
|
|
expect(route).to.equal(url);
|
2022-07-01 15:47:48 +00:00
|
|
|
|
2022-08-30 21:09:44 +00:00
|
|
|
const searchParams = new URLSearchParams(params);
|
2022-07-01 15:47:48 +00:00
|
|
|
|
2022-09-01 14:58:57 +00:00
|
|
|
for (const [key, value] of Object.entries(query)) {
|
|
|
|
expect(searchParams.get(key)).to.equal(value);
|
|
|
|
}
|
2022-08-30 21:09:44 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('SSG images - build', function () {
|
|
|
|
let fixture;
|
|
|
|
let $;
|
|
|
|
let html;
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
fixture = await loadFixture({ root: './fixtures/basic-image/' });
|
|
|
|
await fixture.build();
|
|
|
|
|
|
|
|
html = await fixture.readFile('/index.html');
|
|
|
|
$ = cheerio.load(html);
|
|
|
|
});
|
|
|
|
|
|
|
|
function verifyImage(pathname, expected) {
|
2023-01-30 20:31:49 +00:00
|
|
|
const dist = join(
|
|
|
|
fileURLToPath(new URL('.', import.meta.url)),
|
|
|
|
'fixtures/basic-image/dist',
|
|
|
|
pathname
|
|
|
|
);
|
2022-08-30 21:09:44 +00:00
|
|
|
const result = sizeOf(dist);
|
|
|
|
expect(result).to.deep.equal(expected);
|
|
|
|
}
|
|
|
|
|
2022-09-01 14:58:57 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
title: 'Local images',
|
|
|
|
id: '#social-jpg',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/_astro\/social.\w{8}_\w{4,10}.jpg/,
|
2022-09-01 15:01:07 +00:00
|
|
|
size: { width: 506, height: 253, type: 'jpg' },
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
2022-09-01 20:31:53 +00:00
|
|
|
{
|
|
|
|
title: 'Filename with spaces',
|
|
|
|
id: '#spaces',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/_astro\/introducing astro.\w{8}_\w{4,10}.webp/,
|
2022-09-01 20:31:53 +00:00
|
|
|
size: { width: 768, height: 414, type: 'webp' },
|
|
|
|
},
|
2023-01-30 20:29:41 +00:00
|
|
|
{
|
|
|
|
title: 'File outside src',
|
|
|
|
id: '#outside-src',
|
|
|
|
regex: /^\/_astro\/social.\w{8}_\w{4,10}.png/,
|
|
|
|
size: { type: 'png', width: 2024, height: 1012 },
|
|
|
|
},
|
2023-02-15 08:21:41 +00:00
|
|
|
{
|
|
|
|
title: 'SVG image',
|
|
|
|
id: '#logo-svg',
|
|
|
|
regex: /^\/_astro\/logo.\w{8}_\w{4,10}.svg/,
|
|
|
|
size: { width: 192, height: 256, type: 'svg' },
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
{
|
|
|
|
title: 'Inline imports',
|
|
|
|
id: '#inline',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/_astro\/social.\w{8}_\w{4,10}.jpg/,
|
2022-09-01 15:01:07 +00:00
|
|
|
size: { width: 506, height: 253, type: 'jpg' },
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Remote images',
|
|
|
|
id: '#google',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/_astro\/googlelogo_color_272x92dp_\w{4,10}.webp/,
|
2022-09-01 15:01:07 +00:00
|
|
|
size: { width: 544, height: 184, type: 'webp' },
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
2022-09-07 13:56:07 +00:00
|
|
|
{
|
|
|
|
title: 'Remote without file extension',
|
|
|
|
id: '#ipsum',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/_astro\/200x300_\w{4,10}/,
|
2022-09-07 13:56:07 +00:00
|
|
|
size: { width: 200, height: 300, type: 'jpg' },
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
{
|
|
|
|
title: 'Public images',
|
|
|
|
id: '#hero',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/_astro\/hero_\w{4,10}.webp/,
|
2022-09-01 15:01:07 +00:00
|
|
|
size: { width: 768, height: 414, type: 'webp' },
|
|
|
|
},
|
2022-09-07 17:22:11 +00:00
|
|
|
{
|
|
|
|
title: 'Remote images',
|
|
|
|
id: '#bg-color',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/_astro\/googlelogo_color_272x92dp_\w{4,10}.jpeg/,
|
2022-09-07 17:22:11 +00:00
|
|
|
size: { width: 544, height: 184, type: 'jpg' },
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
].forEach(({ title, id, regex, size }) => {
|
2022-09-29 21:20:48 +00:00
|
|
|
it(title, async () => {
|
2022-09-01 14:58:57 +00:00
|
|
|
const image = $(id);
|
|
|
|
|
|
|
|
expect(image.attr('src')).to.match(regex);
|
|
|
|
expect(image.attr('width')).to.equal(size.width.toString());
|
|
|
|
expect(image.attr('height')).to.equal(size.height.toString());
|
2022-09-01 15:01:07 +00:00
|
|
|
|
2022-09-01 14:58:57 +00:00
|
|
|
verifyImage(image.attr('src'), size);
|
2022-09-29 21:20:48 +00:00
|
|
|
|
2022-09-29 21:22:49 +00:00
|
|
|
const url = new URL(
|
|
|
|
'./fixtures/basic-image/node_modules/.astro/image' + image.attr('src'),
|
|
|
|
import.meta.url
|
|
|
|
);
|
2022-09-29 21:20:48 +00:00
|
|
|
expect(await fs.stat(url), 'transformed image was cached').to.not.be.undefined;
|
2022-09-01 15:01:07 +00:00
|
|
|
});
|
|
|
|
});
|
2022-08-30 21:09:44 +00:00
|
|
|
});
|
2022-07-01 15:47:48 +00:00
|
|
|
|
2022-08-30 21:09:44 +00:00
|
|
|
describe('SSG images with subpath - build', function () {
|
|
|
|
let fixture;
|
|
|
|
let $;
|
|
|
|
let html;
|
2022-07-01 15:47:48 +00:00
|
|
|
|
2022-08-30 21:09:44 +00:00
|
|
|
before(async () => {
|
|
|
|
fixture = await loadFixture({ root: './fixtures/basic-image/', base: '/docs' });
|
|
|
|
await fixture.build();
|
2022-08-22 19:45:34 +00:00
|
|
|
|
2022-08-30 21:09:44 +00:00
|
|
|
html = await fixture.readFile('/index.html');
|
|
|
|
$ = cheerio.load(html);
|
|
|
|
});
|
2022-08-22 19:45:34 +00:00
|
|
|
|
2022-08-30 21:09:44 +00:00
|
|
|
function verifyImage(pathname, expected) {
|
|
|
|
const url = new URL('./fixtures/basic-image/dist/' + pathname, import.meta.url);
|
|
|
|
const dist = fileURLToPath(url);
|
|
|
|
const result = sizeOf(dist);
|
|
|
|
expect(result).to.deep.equal(expected);
|
|
|
|
}
|
|
|
|
|
2022-09-01 14:58:57 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
title: 'Local images',
|
|
|
|
id: '#social-jpg',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/docs\/_astro\/social.\w{8}_\w{4,10}.jpg/,
|
2022-09-01 15:01:07 +00:00
|
|
|
size: { width: 506, height: 253, type: 'jpg' },
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
2022-09-01 20:31:53 +00:00
|
|
|
{
|
|
|
|
title: 'Filename with spaces',
|
|
|
|
id: '#spaces',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/docs\/_astro\/introducing astro.\w{8}_\w{4,10}.webp/,
|
2022-09-01 20:31:53 +00:00
|
|
|
size: { width: 768, height: 414, type: 'webp' },
|
|
|
|
},
|
2023-01-30 20:29:41 +00:00
|
|
|
{
|
|
|
|
title: 'File outside src',
|
|
|
|
id: '#outside-src',
|
|
|
|
regex: /^\/docs\/_astro\/social.\w{8}_\w{4,10}.png/,
|
|
|
|
size: { type: 'png', width: 2024, height: 1012 },
|
|
|
|
},
|
2023-02-15 08:21:41 +00:00
|
|
|
{
|
|
|
|
title: 'SVG image',
|
|
|
|
id: '#logo-svg',
|
|
|
|
regex: /^\/docs\/_astro\/logo.\w{8}_\w{4,10}.svg/,
|
|
|
|
size: { width: 192, height: 256, type: 'svg' },
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
{
|
|
|
|
title: 'Inline imports',
|
|
|
|
id: '#inline',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/docs\/_astro\/social.\w{8}_\w{4,10}.jpg/,
|
2022-09-01 15:01:07 +00:00
|
|
|
size: { width: 506, height: 253, type: 'jpg' },
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Remote images',
|
|
|
|
id: '#google',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/docs\/_astro\/googlelogo_color_272x92dp_\w{4,10}.webp/,
|
2022-09-01 15:01:07 +00:00
|
|
|
size: { width: 544, height: 184, type: 'webp' },
|
2022-09-01 14:58:57 +00:00
|
|
|
},
|
2022-09-07 13:56:07 +00:00
|
|
|
{
|
|
|
|
title: 'Remote without file extension',
|
|
|
|
id: '#ipsum',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/docs\/_astro\/200x300_\w{4,10}/,
|
2022-09-07 13:56:07 +00:00
|
|
|
size: { width: 200, height: 300, type: 'jpg' },
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
{
|
|
|
|
title: 'Public images',
|
|
|
|
id: '#hero',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/docs\/_astro\/hero_\w{4,10}.webp/,
|
2022-09-01 15:01:07 +00:00
|
|
|
size: { width: 768, height: 414, type: 'webp' },
|
|
|
|
},
|
2022-09-07 17:22:11 +00:00
|
|
|
{
|
|
|
|
title: 'Remote images',
|
|
|
|
id: '#bg-color',
|
2023-01-09 16:01:33 +00:00
|
|
|
regex: /^\/docs\/_astro\/googlelogo_color_272x92dp_\w{4,10}.jpeg/,
|
2022-09-07 17:22:11 +00:00
|
|
|
size: { width: 544, height: 184, type: 'jpg' },
|
|
|
|
},
|
2022-09-01 14:58:57 +00:00
|
|
|
].forEach(({ title, id, regex, size }) => {
|
|
|
|
it(title, () => {
|
|
|
|
const image = $(id);
|
|
|
|
|
|
|
|
expect(image.attr('src')).to.match(regex);
|
|
|
|
expect(image.attr('width')).to.equal(size.width.toString());
|
|
|
|
expect(image.attr('height')).to.equal(size.height.toString());
|
2022-09-01 15:01:07 +00:00
|
|
|
|
2022-09-01 14:58:57 +00:00
|
|
|
verifyImage(image.attr('src').replace('/docs', ''), size);
|
2022-09-01 15:01:07 +00:00
|
|
|
});
|
2022-08-30 21:09:44 +00:00
|
|
|
});
|
2022-07-01 15:47:48 +00:00
|
|
|
});
|