Files
AndreaSlopFotografie/web/src/lib/backToTopThreshold.test.ts
T
SluijsensandClaude Opus 5.5 4d6408b607 Completes the front-end shell with footer, status pages and SEO
Adds the footer, back-to-top button, skip link, placeholder routes,
404 and error pages inside the shell, plus per-page SEO from a single
page registry (canonical URLs, Open Graph image, JSON-LD, generated
sitemap.xml and robots.txt).

Theme tokens and recipes replace repeated styling, the hero loads only
the active and neighbouring slides, and the e-mail address is joined
in the browser to keep it out of the HTML and bundle.

Adds Vitest with property-based (fast-check) and axe tests, ESLint,
security headers for dev and preview, Lighthouse CI and a `pnpm check`
script that runs all quality gates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 17:05:02 +02:00

44 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { backToTopThreshold } from './backToTopThreshold';
describe('backToTopThreshold', () => {
it('is 60% van de viewporthoogte', () => {
expect(backToTopThreshold(1000)).toBe(600);
});
it('geeft 0 bij ongeldige hoogtes', () => {
for (const h of [0, -10, NaN, Infinity, -Infinity]) {
expect(backToTopThreshold(h)).toBe(0);
}
});
it('ligt altijd tussen 0 en de hoogte (invariant)', () => {
fc.assert(
fc.property(fc.double({ min: 0, max: 1e7, noNaN: true }), (h) => {
const t = backToTopThreshold(h);
return t >= 0 && t <= h;
}),
);
});
it('stijgt mee met de hoogte bij eindige waarden (monotoon)', () => {
const finite = fc.double({ noNaN: true, noDefaultInfinity: true });
fc.assert(
fc.property(finite, finite, (a, b) => {
const [lo, hi] = a <= b ? [a, b] : [b, a];
return backToTopThreshold(lo) <= backToTopThreshold(hi);
}),
);
});
it('volgt het model 0.6 × max(0, h) (oracle)', () => {
fc.assert(
fc.property(fc.double(), (h) => {
const model = Number.isFinite(h) ? 0.6 * Math.max(0, h) : 0;
expect(backToTopThreshold(h)).toBe(model);
}),
);
});
});