Adds the fallbacks for visitors without JavaScript
The mobile menu works through CSS, and controls that need JavaScript are hidden without it. The contact photo gets its own preload, and the tests cover the new Reveal behaviour, the first row and the noscript markup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,7 @@ import {
|
||||
pageHead,
|
||||
person,
|
||||
personId,
|
||||
preloadImage,
|
||||
professionalService,
|
||||
shootPageGraph,
|
||||
shootService,
|
||||
@@ -43,6 +44,7 @@ import {
|
||||
import sitePages from './sitePages';
|
||||
import {
|
||||
anySiteContent,
|
||||
contentImage,
|
||||
faqItems,
|
||||
knownRoutePath,
|
||||
knowsAboutEntries,
|
||||
@@ -971,3 +973,60 @@ describe('galleryImages', () => {
|
||||
expect(script).not.toMatch(/@[a-z0-9-]+\.[a-z]/i);
|
||||
});
|
||||
});
|
||||
|
||||
describe('preloadImage', () => {
|
||||
const photo = {
|
||||
src: '/assets/contact-abc.jpg',
|
||||
alt: 'Een foto',
|
||||
width: 800,
|
||||
height: 1200,
|
||||
};
|
||||
|
||||
it('preloads the photo at high priority for every width', () => {
|
||||
expect(preloadImage(photo)).toEqual({
|
||||
rel: 'preload',
|
||||
as: 'image',
|
||||
href: '/assets/contact-abc.jpg',
|
||||
fetchPriority: 'high',
|
||||
});
|
||||
});
|
||||
|
||||
it('binds the preload to a media query when given one', () => {
|
||||
expect(preloadImage(photo, { media: '(min-width: 64em)' })).toEqual({
|
||||
rel: 'preload',
|
||||
as: 'image',
|
||||
href: '/assets/contact-abc.jpg',
|
||||
fetchPriority: 'high',
|
||||
media: '(min-width: 64em)',
|
||||
});
|
||||
});
|
||||
|
||||
it('leaves out an empty options object and an empty media', () => {
|
||||
expect(preloadImage(photo, {})).toEqual(preloadImage(photo));
|
||||
expect(preloadImage(photo, { media: '' })).toEqual(preloadImage(photo));
|
||||
});
|
||||
|
||||
it('points at the image with the fixed link fields, and adds media only when given (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(
|
||||
contentImage,
|
||||
fc.option(fc.stringMatching(/^\(min-width: \d{1,3}em\)$/), {
|
||||
nil: undefined,
|
||||
}),
|
||||
(image, media) => {
|
||||
const link = preloadImage(image, { media });
|
||||
expect(link.href).toBe(image.src);
|
||||
expect(link.rel).toBe('preload');
|
||||
expect(link.as).toBe('image');
|
||||
expect(link.fetchPriority).toBe('high');
|
||||
expect(link.media).toBe(media);
|
||||
expect(Object.keys(link).sort()).toEqual(
|
||||
media
|
||||
? ['as', 'fetchPriority', 'href', 'media', 'rel']
|
||||
: ['as', 'fetchPriority', 'href', 'rel'],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user