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>
57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
import fc from 'fast-check';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { slidesToLoad } from './slidesToLoad';
|
|
|
|
describe('slidesToLoad', () => {
|
|
it('laadt de actieve, de volgende en de vorige slide', () => {
|
|
expect(slidesToLoad(3, 8)).toEqual([3, 4, 2]);
|
|
});
|
|
|
|
it('loopt rond: vanaf de eerste is de vorige de laatste', () => {
|
|
expect(slidesToLoad(0, 8)).toEqual([0, 1, 7]);
|
|
expect(slidesToLoad(7, 8)).toEqual([7, 0, 6]);
|
|
});
|
|
|
|
it('werkt met weinig of geen slides', () => {
|
|
expect(slidesToLoad(0, 1)).toEqual([0]);
|
|
expect(slidesToLoad(0, 2)).toEqual([0, 1]);
|
|
expect(slidesToLoad(0, 0)).toEqual([]);
|
|
expect(slidesToLoad(0, 2.5)).toEqual([]);
|
|
});
|
|
|
|
it('geeft unieke geldige indexen, de actieve voorop (invariant)', () => {
|
|
fc.assert(
|
|
fc.property(
|
|
fc.integer({ min: 1, max: 50 }),
|
|
fc.integer({ min: -100, max: 100 }),
|
|
(count, active) => {
|
|
const result = slidesToLoad(active, count);
|
|
expect(new Set(result).size).toBe(result.length);
|
|
expect(result).toHaveLength(Math.min(count, 3));
|
|
expect(result.every((i) => i >= 0 && i < count)).toBe(true);
|
|
expect(result[0]).toBe(((active % count) + count) % count);
|
|
},
|
|
),
|
|
);
|
|
});
|
|
|
|
it('elke buurslide ligt een stap voor of achter de actieve (oracle)', () => {
|
|
fc.assert(
|
|
fc.property(
|
|
fc.integer({ min: 1, max: 50 }),
|
|
fc.nat(),
|
|
(count, active) => {
|
|
const current = active % count;
|
|
for (const i of slidesToLoad(active, count)) {
|
|
const distance = Math.min(
|
|
(i - current + count) % count,
|
|
(current - i + count) % count,
|
|
);
|
|
expect(distance).toBeLessThanOrEqual(1);
|
|
}
|
|
},
|
|
),
|
|
);
|
|
});
|
|
});
|