import { describe, it, expect } from 'vitest'; import { cleanChannelCard } from '../clean-channel-card'; describe('cleanChannelCard', () => { it('полные данные', () => { const raw = { guid: 'ch-1', name: 'Channel', url: '/channel/1', videos_count: 200, is_network: true, updated: 1700000000, avatar_url: 'https://img.com/avatar.jpg', video_thumb_urls: { webp: { '320x180': 'https://img.com/s.webp', '480x270': 'https://img.com/m.webp', }, }, description: 'Channel desc', }; const result = cleanChannelCard(raw as any); expect(result.guid).toBe('ch-1'); expect(result.name).toBe('Channel'); expect(result.videosCount).toBe(200); expect(result.isNetwork).toBe(true); expect(result.avatarUrl).toBe('https://img.com/avatar.jpg'); expect(result.thumbUrls).toEqual({ webp: { '320x180': 'https://img.com/s.webp', '480x270': 'https://img.com/m.webp', }, }); }); it('пустые данные → дефолты', () => { const result = cleanChannelCard({} as any); expect(result.guid).toBe(''); expect(result.name).toBe(''); expect(result.videosCount).toBe(0); expect(result.isNetwork).toBe(false); expect(result.thumbUrls).toBeUndefined(); }); });