import { describe, it, expect } from 'vitest'; import { buildWebcamModelLink } from '../build-model-link'; describe('buildWebcamModelLink', () => { const templates = { straight: 'https://go.example.com?userId=abc&path=/{username}&targetDomain=example.com', gay: 'https://go.other.com?userId=def&path={username}', }; it('подставляет имя модели в шаблон ниши', () => { expect(buildWebcamModelLink(templates, 'straight', 'Kate_Pirse')) .toBe('https://go.example.com?userId=abc&path=/Kate_Pirse&targetDomain=example.com'); expect(buildWebcamModelLink(templates, 'gay', 'Zuii_310')) .toBe('https://go.other.com?userId=def&path=Zuii_310'); }); it('имя модели экранируется', () => { expect(buildWebcamModelLink(templates, 'gay', 'a b&c')).toContain('path=a%20b%26c'); }); it('без шаблона ниши остаётся ссылка провайдера', () => { expect(buildWebcamModelLink(templates, 'shemale', 'Model', 'https://provider/click')).toBe('https://provider/click'); expect(buildWebcamModelLink(undefined, 'straight', 'Model', 'https://provider/click')).toBe('https://provider/click'); }); it('без имени модели ссылку не собираем', () => { expect(buildWebcamModelLink(templates, 'straight', '')).toBe(''); }); });