mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 10:26:57 +00:00
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
getPresetAvatarBuffer,
|
|
getPresetAvatarStorageKey,
|
|
isPresetAvatarId,
|
|
PRESET_AVATAR_IDS,
|
|
type PresetAvatarId,
|
|
} from './presets'
|
|
|
|
describe('agent presets', () => {
|
|
it('identifies preset avatar IDs correctly', () => {
|
|
expect(PRESET_AVATAR_IDS).toHaveLength(8)
|
|
for (const id of PRESET_AVATAR_IDS) {
|
|
expect(isPresetAvatarId(id)).toBe(true)
|
|
}
|
|
expect(isPresetAvatarId('avatar-999')).toBe(false)
|
|
expect(isPresetAvatarId('')).toBe(false)
|
|
expect(isPresetAvatarId(null)).toBe(false)
|
|
expect(isPresetAvatarId(undefined)).toBe(false)
|
|
})
|
|
|
|
it('returns valid buffer for all preset avatars', () => {
|
|
for (const id of PRESET_AVATAR_IDS) {
|
|
const buf = getPresetAvatarBuffer(id)
|
|
expect(buf).toBeInstanceOf(Buffer)
|
|
expect(buf?.length).toBeGreaterThan(5000)
|
|
}
|
|
expect(getPresetAvatarBuffer('unknown' as PresetAvatarId)).toBeNull()
|
|
})
|
|
|
|
it('returns deterministic storage key for preset avatars', () => {
|
|
for (const id of PRESET_AVATAR_IDS) {
|
|
expect(getPresetAvatarStorageKey(id)).toBe(`files/avatars/${id}.webp`)
|
|
}
|
|
})
|
|
|
|
it('provides AVAILABLE_AVATARS with 8 previews via dtos', async () => {
|
|
const { AVAILABLE_AVATARS } = await import('@shumai/dtos')
|
|
expect(AVAILABLE_AVATARS).toHaveLength(8)
|
|
for (const avatar of AVAILABLE_AVATARS) {
|
|
expect(avatar.id).toMatch(/^avatar-[1-8]$/)
|
|
expect(avatar.preview).toMatch(/^data:image\/webp;base64,/)
|
|
}
|
|
})
|
|
})
|