import { describe, it, expect } from 'vitest'; import { cleanUserPlaylistCard } from '../clean-user-playlists-card'; describe('cleanUserPlaylistCard', () => { it('полные данные', () => { const raw = { created: 1700000000, id: 'pl-1', name: 'My Playlist', username: 'user1', playlistType: 'public', thumbs: [ 'https://img.com/1.webp', 'https://img.com/2.webp', 'https://img.com/3.webp', 'https://img.com/4.webp', 'https://img.com/5.webp', ], videoCount: 10, firstVideoID: 'v-1', }; const result = cleanUserPlaylistCard(raw as any); expect(result.id).toBe('pl-1'); expect(result.playlistType).toBe('public'); expect(result.videosCount).toBe(10); expect(result.firstVideoId).toBe('v-1'); expect(result.thumbUrls).toHaveLength(4); // slice(0, 4) expect(result.thumbUrls![0]).toEqual({ webp: { '320x180': 'https://img.com/1.webp' }, }); }); it('пустые данные → дефолты', () => { const result = cleanUserPlaylistCard({} as any); expect(result.id).toBe(''); expect(result.name).toBe(''); expect(result.videosCount).toBe(0); expect(result.thumbUrls).toEqual([]); }); });