ultisuite-client/lib/contact-avatar.test.ts
R3D347HR4Y 07d57f13a8
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
Add Contact Avatar Features and Improve UI Components
- Introduced new ContactAvatar and ContactAvatarPicker components for enhanced avatar management in contact views.
- Updated ContactDetailView and ContactFormView to utilize the new avatar components, improving user experience when adding or editing contacts.
- Enhanced ContactHoverCard and ContactRow components to display avatars, providing a more visually appealing interface.
- Added loading and error states in ContactsListView for better user feedback during data fetching.
- Implemented a new ContactsLoadState component to handle loading and error scenarios in the contacts list.
- Updated package.json to include @formkit/auto-animate for improved UI animations.
2026-06-06 20:26:51 +02:00

47 lines
1.2 KiB
TypeScript

import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import {
avatarUrlToVCardPhotoLine,
gravatarUrl,
parseVCardPhoto,
} from './contact-avatar.ts'
describe('contact-avatar', () => {
it('builds stable Gravatar URL for normalized email', () => {
assert.equal(
gravatarUrl('Alice@Example.COM', 80),
'https://www.gravatar.com/avatar/7206d8c4dd027ffeae12fb6540cbed2ba?s=80&d=404',
)
})
it('parses embedded vCard PHOTO as data URI', () => {
const photo = parseVCardPhoto('PHOTO;ENCODING=b;TYPE=PNG', 'aGVsbG8=')
assert.equal(photo, 'data:image/png;base64,aGVsbG8=')
})
it('parses vCard PHOTO URI', () => {
assert.equal(
parseVCardPhoto('PHOTO;VALUE=URI', 'https://cdn.example/face.jpg'),
'https://cdn.example/face.jpg',
)
})
it('serializes data URI to vCard PHOTO line', () => {
const line = avatarUrlToVCardPhotoLine(
'data:image/jpeg;base64,/9j/abc',
(v) => v,
)
assert.equal(line, 'PHOTO;ENCODING=b;TYPE=JPEG:/9j/abc')
})
it('skips Gravatar URLs when exporting vCard', () => {
assert.equal(
avatarUrlToVCardPhotoLine(
'https://www.gravatar.com/avatar/abc?s=80&d=404',
(v) => v,
),
null,
)
})
})