import { describe, it, expect } from 'vitest'; import { cleanChannelInfo } from '../clean-channel-info'; describe('cleanChannelInfo', () => { it('полные данные', () => { const raw = { guid: 'ch-1', name: 'Channel Name', url: '/channel/1', description: 'desc', videos_count: 100, is_network: false, updated: 1700000000, avatar_url: 'https://img.com/avatar.jpg', video_thumb_urls: { webp: { '320x180': 'https://img.com/s.webp' } }, tags: ['tag1', 'tag2'], }; const result = cleanChannelInfo(raw as any); expect(result.title).toBe('Channel Name'); expect(result.img).toBe('https://img.com/avatar.jpg'); expect(result.tags).toEqual(['tag1', 'tag2']); }); it('без avatar_url → берёт thumb', () => { const raw = { avatar_url: '', video_thumb_urls: { webp: { '320x180': 'https://img.com/thumb.webp' } }, }; const result = cleanChannelInfo(raw as any); expect(result.img).toBe('https://img.com/thumb.webp'); }); it('пустые данные с пустым webp → дефолты', () => { const raw = { video_thumb_urls: { webp: {} } }; const result = cleanChannelInfo(raw as any); expect(result.guid).toBe(''); expect(result.title).toBe(''); expect(result.videosCount).toBe(0); expect(result.tags).toEqual([]); }); });