69 lines
2.7 KiB
TypeScript
69 lines
2.7 KiB
TypeScript
|
|
import { describe, expect, it } from 'vitest';
|
||
|
|
|
||
|
|
import {
|
||
|
|
residentialClientConfirmation,
|
||
|
|
residentialSalesAlert,
|
||
|
|
} from '@/lib/email/templates/residential-inquiry';
|
||
|
|
|
||
|
|
describe('residentialClientConfirmation', () => {
|
||
|
|
it('reflects the chosen residence types in the thank-you copy', async () => {
|
||
|
|
const { html, text } = await residentialClientConfirmation({
|
||
|
|
firstName: 'Mia',
|
||
|
|
contactEmail: 'sales@portnimara.com',
|
||
|
|
residenceTypes: ['Two Bedroom Marina Villa', 'Five Bedroom Oceanfront Villa'],
|
||
|
|
portName: 'Port Nimara',
|
||
|
|
});
|
||
|
|
expect(html).toContain('the Two Bedroom Marina Villa and the Five Bedroom Oceanfront Villa');
|
||
|
|
expect(text).toContain('the Two Bedroom Marina Villa and the Five Bedroom Oceanfront Villa');
|
||
|
|
expect(html).toContain('Mia');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('falls back to a generic phrase when no types are selected', async () => {
|
||
|
|
const { html } = await residentialClientConfirmation({
|
||
|
|
firstName: 'Sam',
|
||
|
|
contactEmail: 'sales@portnimara.com',
|
||
|
|
portName: 'Port Nimara',
|
||
|
|
});
|
||
|
|
expect(html).toContain('the residences at Port Nimara');
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
describe('residentialSalesAlert', () => {
|
||
|
|
it('renders residence type(s) + preferred contact + comments in the detail-line format', async () => {
|
||
|
|
const { html, text } = await residentialSalesAlert({
|
||
|
|
fullName: 'Mia Ng',
|
||
|
|
email: 'mia@example.com',
|
||
|
|
phone: '+15551234',
|
||
|
|
residenceTypes: ['Two Bedroom Marina Villa'],
|
||
|
|
preferredContactMethod: 'phone',
|
||
|
|
notes: 'Looking for a winter completion.',
|
||
|
|
crmDeepLink: 'https://crm.portnimara.com/port-nimara',
|
||
|
|
portName: 'Port Nimara',
|
||
|
|
});
|
||
|
|
// Uniform with the berth/contact alerts: friendly intro + bold detail lines + CRM link.
|
||
|
|
expect(html).toContain('A new residential enquiry has come in');
|
||
|
|
expect(html).toContain('Residence type(s):');
|
||
|
|
expect(html).toContain('Two Bedroom Marina Villa');
|
||
|
|
expect(html).toContain('Preferred contact:');
|
||
|
|
expect(html).toContain('Phone call back');
|
||
|
|
expect(html).toContain('Looking for a winter completion.');
|
||
|
|
expect(html).toContain('to follow up');
|
||
|
|
// Plain-text part mirrors the other alerts.
|
||
|
|
expect(text).toContain('Residence type(s): Two Bedroom Marina Villa');
|
||
|
|
expect(text).toContain('Preferred contact: Phone call back');
|
||
|
|
expect(text).toContain('Comments: Looking for a winter completion.');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('omits optional rows cleanly when absent', async () => {
|
||
|
|
const { html } = await residentialSalesAlert({
|
||
|
|
fullName: 'Bob Smith',
|
||
|
|
email: 'bob@example.com',
|
||
|
|
phone: '+1999',
|
||
|
|
portName: 'Port Nimara',
|
||
|
|
});
|
||
|
|
expect(html).not.toContain('Residence type(s):');
|
||
|
|
expect(html).not.toContain('Preferred contact:');
|
||
|
|
expect(html).toContain('Bob Smith');
|
||
|
|
});
|
||
|
|
});
|