30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { profileAvatarUrl, visibleProfile } from './profile'
|
|
|
|
const profile = {
|
|
id: '00000000-0000-0000-0000-000000000001',
|
|
display_name: 'Aster Vale',
|
|
description: 'Keeper of impossible maps.',
|
|
avatar_path: '00000000-0000-0000-0000-000000000001/avatar',
|
|
created_at: '2026-08-20T10:00:00.000Z',
|
|
updated_at: '2026-08-20T11:00:00.000Z',
|
|
}
|
|
|
|
describe('profile presentation', () => {
|
|
it('builds a cache-busted public avatar URL', () => {
|
|
expect(profileAvatarUrl(profile, 'https://example.supabase.co/')).toBe(
|
|
'https://example.supabase.co/storage/v1/object/public/profile-avatars/00000000-0000-0000-0000-000000000001/avatar?v=2026-08-20T11%3A00%3A00.000Z',
|
|
)
|
|
})
|
|
|
|
it('does not expose the storage path in a visible profile', () => {
|
|
const visible = visibleProfile(profile, 'https://example.supabase.co')
|
|
expect(visible).not.toHaveProperty('avatar_path')
|
|
expect(visible.avatar_url).toContain('/profile-avatars/')
|
|
})
|
|
|
|
it('returns no URL when the profile has no avatar', () => {
|
|
expect(profileAvatarUrl({ ...profile, avatar_path: null }, 'https://example.supabase.co')).toBeNull()
|
|
})
|
|
})
|