Adds the contact form with the live fields, validation and browser-side anti-spam, behind a coming-soon notice with a mail button until the API exists. A "Boek" link on a price card selects its package, tidies the URL and moves focus to the form. The form loads only when it comes near the screen, so the hero does not wait for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import fc from 'fast-check';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { mailSubject, mailtoLink } from './mailLink';
|
|
|
|
describe('mailSubject', () => {
|
|
it('names the package when there is one', () => {
|
|
expect(mailSubject('Newborn')).toBe('Aanvraag fotoshoot: Newborn');
|
|
expect(mailSubject()).toBe('Vraag via andreaslop.nl');
|
|
});
|
|
|
|
it('contains the package name whenever one is given (invariant)', () => {
|
|
fc.assert(
|
|
fc.property(fc.string({ minLength: 1 }), (name) => {
|
|
expect(mailSubject(name)).toContain(name);
|
|
}),
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('mailtoLink', () => {
|
|
it('builds a mail link with an encoded subject', () => {
|
|
expect(mailtoLink('a@b.nl', 'Aanvraag fotoshoot: Gezin')).toBe(
|
|
'mailto:a@b.nl?subject=Aanvraag%20fotoshoot%3A%20Gezin',
|
|
);
|
|
});
|
|
|
|
it('gives back the subject when decoded (round-trip)', () => {
|
|
fc.assert(
|
|
fc.property(fc.string(), (subject) => {
|
|
const link = mailtoLink('a@b.nl', subject);
|
|
expect(link.startsWith('mailto:a@b.nl?subject=')).toBe(true);
|
|
const encoded = link.slice('mailto:a@b.nl?subject='.length);
|
|
expect(decodeURIComponent(encoded)).toBe(subject);
|
|
}),
|
|
);
|
|
});
|
|
});
|