Files
MOPC-Portal/tests/unit/mentor-welcome-email.test.ts

67 lines
2.2 KiB
TypeScript
Raw Normal View History

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',
'Please reach out this week.',
)
expect(t.html).toContain('bob@team.com')
expect(t.html).toContain('How to mentor on MOPC')
expect(t.html).toContain('Please reach out this week.')
expect(t.text).toContain('bob@team.com')
expect(t.text).toContain('How to mentor on MOPC')
})
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!')
})
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')
})
})