39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
buildStakeholderMessage,
|
|
isMailerReady,
|
|
MailerNotReadyError,
|
|
sendConfirmationEmail,
|
|
} from './mailer.js'
|
|
|
|
describe('mailer readiness', () => {
|
|
it('reports missing SMTP configuration without exposing credentials', async () => {
|
|
expect(isMailerReady()).toBe(false)
|
|
await expect(sendConfirmationEmail('test@example.invalid', 'contact', 'synthetic-token'))
|
|
.rejects.toBeInstanceOf(MailerNotReadyError)
|
|
await expect(sendConfirmationEmail('test@example.invalid', 'contact', 'synthetic-token'))
|
|
.rejects.toMatchObject({ code: 'MAILER_NOT_READY' })
|
|
})
|
|
})
|
|
|
|
describe('stakeholder notification content', () => {
|
|
const data = {
|
|
name: 'Synthetic Test',
|
|
email: 'test@example.invalid',
|
|
}
|
|
|
|
it('adds the manual profile instruction to resource requests', () => {
|
|
const message = buildStakeholderMessage('resource-download', data)
|
|
|
|
expect(message).toContain('ein aktuelles Profil von André verschicken')
|
|
expect(message).toContain('name: Synthetic Test')
|
|
})
|
|
|
|
it('does not add the resource instruction to contact notifications', () => {
|
|
const message = buildStakeholderMessage('contact', data)
|
|
|
|
expect(message).not.toContain('ein aktuelles Profil von André verschicken')
|
|
expect(message).toBe('name: Synthetic Test\nemail: test@example.invalid')
|
|
})
|
|
})
|