import { describe, it, expect } from 'vitest' import { getMentorBulkAssignmentTemplate, getTeamMentorIntroductionTemplate, } from '@/lib/email' describe('getMentorBulkAssignmentTemplate', () => { it('includes team-member emails, the instructions block, and a custom note', () => { const t = getMentorBulkAssignmentTemplate( 'Alice', [ { title: 'Reef Project', url: 'https://x/mentor/workspace/1', teamMembers: [{ name: 'Bob', email: 'bob@team.com' }], }, ], 'https://x/mentor', 'Reach out now & soon', ) expect(t.html).toContain('bob@team.com') expect(t.html).toContain('How to mentor on MOPC') // The admin-supplied custom note must be HTML-escaped in the HTML body. expect(t.html).toContain('<b>') expect(t.html).not.toContain('now') expect(t.text).toContain('bob@team.com') expect(t.text).toContain('How to mentor on MOPC') // The plain-text body keeps the raw note unescaped. expect(t.text).toContain('Reach out now & soon') }) it('renders without team members or note (backward compatible)', () => { const t = getMentorBulkAssignmentTemplate( 'Alice', [{ title: 'P', url: 'https://x/p' }], 'https://x/mentor', ) expect(t.html).toContain('How to mentor on MOPC') // Custom-note box uses the #fff7ed background; absent when no note passed. expect(t.html).not.toContain('#fff7ed') }) }) describe('getTeamMentorIntroductionTemplate', () => { it('includes mentor + teammate emails, the instructions block, and a custom note', () => { const t = getTeamMentorIntroductionTemplate( 'Bob', 'Reef Project', [{ name: 'Alice', email: 'alice@mentor.com' }], 'https://x/applicant/mentor', [{ name: 'Carol', email: 'carol@team.com' }], 'Welcome aboard!', ) expect(t.html).toContain('alice@mentor.com') expect(t.html).toContain('carol@team.com') expect(t.html).toContain('Working with your mentor') expect(t.html).toContain('Welcome aboard!') // Mirror coverage on the plain-text path. expect(t.text).toContain('alice@mentor.com') expect(t.text).toContain('carol@team.com') expect(t.text).toContain('Welcome aboard!') }) it('renders without teammates or note (backward compatible)', () => { const t = getTeamMentorIntroductionTemplate( 'Bob', 'Reef Project', [{ name: 'Alice', email: 'alice@mentor.com' }], 'https://x/applicant/mentor', ) expect(t.html).toContain('Working with your mentor') expect(t.html).not.toContain('#fff7ed') }) })