Fix the image tests (#5338)

* Fix the image tests

* fix more base tests
This commit is contained in:
Matthew Phillips 2022-11-09 10:22:53 -05:00 committed by GitHub
parent 230d71f4b7
commit faa01cec73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 8 deletions

View file

@ -2,6 +2,7 @@
import socialJpg from '../assets/social.jpg';
import introJpg from '../assets/blog/introducing astro.jpg';
import { Image } from '@astrojs/image/components';
const publicImage = new URL('./hero.jpg', Astro.url);
---
<html>
@ -9,7 +10,7 @@ import { Image } from '@astrojs/image/components';
<!-- Head Stuff -->
</head>
<body>
<Image id="hero" src="/hero.jpg" width={768} height={414} format="webp" alt="hero" />
<Image id="hero" src={publicImage.pathname} width={768} height={414} format="webp" alt="hero" />
<br />
<Image id="spaces" src={introJpg} width={768} height={414} format="webp" alt="spaces" />
<br />

View file

@ -2,6 +2,7 @@
import socialJpg from '../assets/social.jpg';
import introJpg from '../assets/blog/introducing astro.jpg';
import { Picture } from '@astrojs/image/components';
const publicImage = new URL('./hero.jpg', Astro.url);
---
<html>
@ -9,7 +10,7 @@ import { Picture } from '@astrojs/image/components';
<!-- Head Stuff -->
</head>
<body>
<Picture id="hero" src="/hero.jpg" sizes="100vw" widths={[384, 768]} aspectRatio={768/414} alt="Hero image" />
<Picture id="hero" src={publicImage.pathname} sizes="100vw" widths={[384, 768]} aspectRatio={768/414} alt="Hero image" />
<br />
<Picture id="spaces" src={introJpg} sizes="100vw" widths={[384, 768]} aspectRatio={768/414} alt="spaces" />
<br />

View file

@ -164,7 +164,7 @@ describe('SSG images with subpath - dev', function () {
title: 'Public images',
id: '#hero',
url: '/_image',
query: { f: 'webp', w: '768', h: '414', href: '/hero.jpg' },
query: { f: 'webp', w: '768', h: '414', href: '/docs/hero.jpg' },
},
{
title: 'Background color',

View file

@ -186,7 +186,7 @@ describe('SSR images with subpath - build', function () {
title: 'Public images',
id: '#hero',
url: '/_image',
query: { f: 'webp', w: '768', h: '414', href: '/hero.jpg' },
query: { f: 'webp', w: '768', h: '414', href: '/docs/hero.jpg' },
},
{
title: 'Background color',

View file

@ -199,7 +199,7 @@ describe('SSR images with subpath - dev', function () {
f: 'webp',
w: '768',
h: '414',
href: '/hero.jpg',
href: '/docs/hero.jpg',
},
contentType: 'image/webp',
},

View file

@ -154,7 +154,7 @@ describe('SSG pictures with subpath - dev', function () {
title: 'Public images',
id: '#hero',
url: '/_image',
query: { f: 'jpg', w: '768', h: '414', href: '/hero.jpg' },
query: { f: 'jpg', w: '768', h: '414', href: '/docs/hero.jpg' },
alt: 'Hero image',
},
].forEach(({ title, id, url, query, alt }) => {

View file

@ -175,7 +175,7 @@ describe('SSR pictures with subpath - build', function () {
title: 'Public images',
id: '#hero',
url: '/_image',
query: { f: 'jpg', w: '768', h: '414', href: '/hero.jpg' },
query: { f: 'jpg', w: '768', h: '414', href: '/docs/hero.jpg' },
alt: 'Hero image',
},
{

View file

@ -213,7 +213,7 @@ describe('SSR pictures with subpath - dev', function () {
f: 'jpg',
w: '768',
h: '414',
href: '/hero.jpg',
href: '/docs/hero.jpg',
},
contentType: 'image/jpeg',
alt: 'Hero image',