teqo/tests/unit/campaignUserProfile.unit.spec.ts
Francisco Ignácio Fontoura Solla 3b463173da Add campaign password reset, profile photo, and RS+ follow-up plan.
Deliver self-service forgot/reset via Resend, logged-in password change, and optional avatar on /campanha/perfil; register post-simplify engineering debts as RS+.
2026-07-19 05:26:56 -03:00

37 lines
1 KiB
TypeScript

// @vitest-environment node
import { describe, expect, it } from 'vitest'
import {
assertCampaignAvatarFile,
campaignUserInitials,
campaignUserShellView,
mediaDocumentUrl,
} from '@/utilities/campaignUserProfile'
describe('campaignUserProfile helpers', () => {
it('builds initials from the user name', () => {
expect(campaignUserInitials('Maria Silva')).toBe('MS')
expect(campaignUserInitials('João')).toBe('J')
})
it('builds shell view from a campaign user', () => {
expect(
campaignUserShellView({
name: 'Maria',
role: 'geral',
avatar: { id: 1, url: 'https://example.com/a.jpg' } as never,
}),
).toEqual({
name: 'Maria',
role: 'geral',
avatarUrl: 'https://example.com/a.jpg',
})
expect(mediaDocumentUrl(42)).toBeNull()
})
it('rejects unsupported avatar mime types', () => {
const file = new File(['x'], 'avatar.gif', { type: 'image/gif' })
expect(() => assertCampaignAvatarFile(file)).toThrow(/JPEG, PNG ou WebP/)
})
})