Adds the Lieve woorden section to the homepage
Shows client reviews one at a time with the framed photo, a large quotation mark, the shoot type and the names. Uses Chakra's carousel for paging, looping and swiping with our own controls, so visitors who prefer reduced motion get instant changes, and loads the carousel only when the section comes near the screen so the hero does not wait for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import fc from 'fast-check';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import testimonials from '../content/testimonials';
|
||||
import { anyTestimonial, uniqueTestimonials } from '../test/arbitraries';
|
||||
import { isValidTestimonial, visibleTestimonials } from './visibleTestimonials';
|
||||
|
||||
const valid = testimonials[0];
|
||||
|
||||
describe('visibleTestimonials', () => {
|
||||
it('keeps the live reviews as they are', () => {
|
||||
expect(visibleTestimonials(testimonials)).toEqual(testimonials);
|
||||
});
|
||||
|
||||
it('skips reviews that break an invariant', () => {
|
||||
const broken = [
|
||||
{ ...valid, id: ' ' },
|
||||
{ ...valid, id: 'zonder-shoot', shoot: '' },
|
||||
{ ...valid, id: 'zonder-tekst', quote: ' ' },
|
||||
{ ...valid, id: 'zonder-naam', author: '' },
|
||||
{ ...valid, id: 'zonder-foto', image: { ...valid.image, src: '' } },
|
||||
{ ...valid, id: 'nul-breed', image: { ...valid.image, width: 0 } },
|
||||
{ ...valid, id: 'nul-hoog', image: { ...valid.image, height: 0 } },
|
||||
];
|
||||
expect(visibleTestimonials([...broken, valid])).toEqual([valid]);
|
||||
});
|
||||
|
||||
it('keeps the first of two reviews with the same id', () => {
|
||||
expect(
|
||||
visibleTestimonials([valid, { ...valid, author: 'Dubbel' }]),
|
||||
).toEqual([valid]);
|
||||
});
|
||||
|
||||
it('only returns valid reviews with unique ids (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(fc.array(anyTestimonial), (input) => {
|
||||
const result = visibleTestimonials(input);
|
||||
expect(result.every(isValidTestimonial)).toBe(true);
|
||||
const ids = result.map((item) => item.id);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('is a subsequence of the input in the same order (invariant)', () => {
|
||||
fc.assert(
|
||||
fc.property(fc.array(anyTestimonial), (input) => {
|
||||
const result = visibleTestimonials(input);
|
||||
let i = 0;
|
||||
for (const item of input) {
|
||||
if (item === result[i]) i++;
|
||||
}
|
||||
return i === result.length;
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('is idempotent', () => {
|
||||
fc.assert(
|
||||
fc.property(fc.array(anyTestimonial), (input) => {
|
||||
const once = visibleTestimonials(input);
|
||||
expect(visibleTestimonials(once)).toEqual(once);
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('returns valid, unique reviews unchanged (oracle)', () => {
|
||||
fc.assert(
|
||||
fc.property(uniqueTestimonials, (input) => {
|
||||
expect(visibleTestimonials(input)).toEqual(input);
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user