Return

All tests / src/components/BackgroundImage index.tsx

100% Statements 8/8
100% Branches 0/0
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 443x 3x 3x 3x               3x 4x                                                           4x  
import Image from 'next/image';
import styles from './backgroundImage.module.css';
import backgroundImage from '../../../public/background-image.jpeg';
import { useIntl } from 'react-intl';
 
/**
 * @example
 *     <BackgroundImage />;
 *
 * @returns {JSX.Element}
 */
const BackgroundImage = () => {
    const { formatMessage: f } = useIntl();
    return (
        <div className={styles.bgWrap}>
            <Image
                fill
                /**
                 * SDD-L03. This is the LCP candidate on every URL — `Layout` mounts it site-wide,
                 * `fill` + `objectFit: cover` over a fixed full-screen wrapper.
                 *
                 * It carried `loading="eager"` and `quality={100}` and no `priority`, which was the
                 * wrong pair of both. `loading="eager"` only disables lazy-loading; `priority` is what
                 * emits `fetchpriority="high"` and a `<link rel="preload">`. Meanwhile the five 60px
                 * Dock icons *did* carry `priority`, so five decorative preloads outranked the LCP
                 * image. And `quality={100}` delivered 222 KB where the default 75 delivers 19 KB —
                 * measured with the project's own sharp against this source, a factor of 11.7.
                 */
                priority
                data-testid="background-image"
                sizes="100vw"
                placeholder="blur"
                src={backgroundImage}
                alt={f({ id: 'background.image.alt' })}
                style={{
                    objectFit: 'cover',
                }}
            />
        </div>
    );
};
 
export default BackgroundImage;