66117d375e
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
25 lines
1.1 KiB
TypeScript
25 lines
1.1 KiB
TypeScript
import { describe, test, expect } from 'vitest';
|
|
import { ContactForm } from './ContactForm';
|
|
|
|
const toHtml = (ContactForm as any).toHtml;
|
|
|
|
describe('ContactForm.toHtml relay wiring', () => {
|
|
test('with recipientEmail: emits marker, placeholder action, honeypot', () => {
|
|
const { html } = toHtml({ recipientEmail: 'a@b.com', thankYouUrl: '/thx', fields: [] }, '');
|
|
expect(html).toMatch(/<!--WHP-FORM id="F[0-9a-z]+" recipient="a@b.com" thankyou="\/thx"-->/);
|
|
expect(html).toMatch(/action="__WHP_FORM_ACTION__F[0-9a-z]+__"/);
|
|
expect(html).toContain('method="POST"');
|
|
expect(html).toContain('name="_gotcha"');
|
|
// marker id and action id match
|
|
const mid = html.match(/id="(F[0-9a-z]+)"/)![1];
|
|
expect(html).toContain(`__WHP_FORM_ACTION__${mid}__`);
|
|
});
|
|
|
|
test('without recipientEmail: no marker, falls back to formAction', () => {
|
|
const { html } = toHtml({ formAction: '/legacy', fields: [] }, '');
|
|
expect(html).not.toContain('WHP-FORM');
|
|
expect(html).toContain('action="/legacy"');
|
|
expect(html).not.toContain('_gotcha');
|
|
});
|
|
});
|